Topic: Problems compiling when using flibs and opengl

I am trying to use the m_vfile module in flibs to construct a file manager, however when I call functions in that module I get the following errors:


C:/Users/AnthonyG/AppData/Local///sfpm/32/lib\libflibs-filedir.a(m_vfile.o): In function `_m_vfile_MOD_vfile_shutdown':
C:\Users\Jeffrey\Workspace\sfpm\packages\flibs\projects/../src/filedir/m_vfile.f90:3702: undefined reference to `__m_vstring_MOD_vstring_free'
C:\Users\Jeffrey\Workspace\sfpm\packages\flibs\projects/../src/filedir/m_vfile.f90:3703: undefined reference to `__m_vstring_MOD_vstring_free'
C:\Users\Jeffrey\Workspace\sfpm\packages\flibs\projects/../src/filedir/m_vfile.f90:3704: undefined reference to `__m_vstring_MOD_vstring_free'
C:\Users\Jeffrey\Workspace\sfpm\packages\flibs\projects/../src/filedir/m_vfile.f90:3705: undefined reference to `__m_vstring_MOD_vstring_free'
C:\Users\Jeffrey\Workspace\sfpm\packages\flibs\projects/../src/filedir/m_vfile.f90:3706: undefined reference to `__m_vstring_MOD_vstring_free'
C:/Users/AnthonyG/AppData/Local///sfpm/32/lib\libflibs-filedir.a(m_vfile.o):C:\Users\Jeffrey\Workspace\sfpm\packages\flibs\projects/../src/filedir/m_vfile.f90:3707: more undefined references to `__m_vstring_MOD_vstring_free' follow
C:/Users/AnthonyG/AppData/Local///sfpm/32/lib\libflibs-filedir.a(m_vfile.o): In function `_m_vfile_MOD_vfile_startup':
C:\Users\Jeffrey\Workspace\sfpm\packages\flibs\projects/../src/filedir/m_vfile.f90:3631: undefined reference to `__m_platform_MOD_platform_get_platform'
C:\Users\Jeffrey\Workspace\sfpm\packages\flibs\projects/../src/filedir/m_vfile.f90:3632: undefined reference to `__m_vstringformat_MOD_vstring_format_auto_integer_kind4'
C:\Users\Jeffrey\Workspace\sfpm\packages\flibs\projects/../src/filedir/m_vfile.f90:3645: undefined reference to `__m_vstring_MOD_vstring_new_empty'
...
...
(many more of the same error messages)
...
...

collect2.exe: error: ld returned 1 exit status
Error(E42): Last command making (RAS.exe) returned a bad status
Error(E02): Make execution terminated

* Failed *


The included flibs demo file test_m_filedir.f90 compiles and executes fine (although it doesn't use m_vfile), however the demo file myfprog.f90 for sqlite generates the same errors as above. I also have similar problems compiling the opengl demo:


Warning: resolving _glMatrixMode by linking to _glMatrixMode@4
Use --enable-stdcall-fixup to disable these warnings
Use --disable-stdcall-fixup to disable these fixups
Warning: resolving _glLoadIdentity by linking to _glLoadIdentity@0
Warning: resolving _glTranslatef by linking to _glTranslatef@12
Warning: resolving _glDisable by linking to _glDisable@4
Warning: resolving _glPushMatrix by linking to _glPushMatrix@0
Warning: resolving _glPopMatrix by linking to _glPopMatrix@0
Warning: resolving _glFlush by linking to _glFlush@0
Warning: resolving _glBegin by linking to _glBegin@4
Warning: resolving _glEnd by linking to _glEnd@0
Warning: resolving _glColor4fv by linking to _glColor4fv@4
build\scube.o: In function `MAIN__':
C:\Users\AnthonyG\Documents/./scube.f90:59: undefined reference to `glFrustum'
C:\Users\AnthonyG\Documents/./scube.f90:65: undefined reference to `glEnable'
C:\Users\AnthonyG\Documents/./scube.f90:68: undefined reference to `glEnable'
C:\Users\AnthonyG\Documents/./scube.f90:70: undefined reference to `glEnable'
C:\Users\AnthonyG\Documents/./scube.f90:71: undefined reference to `glLightfv'
C:\Users\AnthonyG\Documents/./scube.f90:72: undefined reference to `glLightfv'
C:\Users\AnthonyG\Documents/./scube.f90:73: undefined reference to `glLightfv'
C:\Users\AnthonyG\Documents/./scube.f90:74: undefined reference to `glLightfv'
C:\Users\AnthonyG\Documents/./scube.f90:80: undefined reference to `glEnable'
C:\Users\AnthonyG\Documents/./scube.f90:83: undefined reference to `glEnable'
C:\Users\AnthonyG\Documents/./scube.f90:85: undefined reference to `glFogfv'
C:\Users\AnthonyG\Documents/./scube.f90:86: undefined reference to `glFogfv'
C:\Users\AnthonyG\Documents/./scube.f90:88: undefined reference to `glFogf'
C:\Users\AnthonyG\Documents/./scube.f90:89: undefined reference to `glFogf'
C:\Users\AnthonyG\Documents/./scube.f90:90: undefined reference to `glFogf'
C:\Users\AnthonyG\Documents/./scube.f90:91: undefined reference to `glFogf'
C:\Users\AnthonyG\Documents/./scube.f90:93: undefined reference to `glEnable'
C:\Users\AnthonyG\Documents/./scube.f90:94: undefined reference to `glCullFace'
C:\Users\AnthonyG\Documents/./scube.f90:96: undefined reference to `glShadeModel'
C:\Users\AnthonyG\Documents/./scube.f90:98: undefined reference to `glBlendFunc'
C:\Users\AnthonyG\Documents/./scube.f90:100: undefined reference to `glPolygonStipple'
C:\Users\AnthonyG\Documents/./scube.f90:102: undefined reference to `glPolygonStipple'
C:\Users\AnthonyG\Documents/./scube.f90:105: undefined reference to `glClearColor'
C:\Users\AnthonyG\Documents/./scube.f90:106: undefined reference to `glClearIndex'
C:\Users\AnthonyG\Documents/./scube.f90:107: undefined reference to `glClearDepth'
build\scube_mod.o: In function `menu_select':
C:\Users\AnthonyG\Documents/./scube_mod.f90:465: undefined reference to `glEnable'
C:\Users\AnthonyG\Documents/./scube_mod.f90:473: undefined reference to `glEnable'
build\scube_mod.o: In function `fog_select':
C:\Users\AnthonyG\Documents/./scube_mod.f90:447: undefined reference to `glFogf'
build\scube_mod.o: In function `display':
C:\Users\AnthonyG\Documents/./scube_mod.f90:371: undefined reference to `glClear'
C:\Users\AnthonyG\Documents/./scube_mod.f90:375: undefined reference to `glRotatef'
C:\Users\AnthonyG\Documents/./scube_mod.f90:376: undefined reference to `glScalef'
C:\Users\AnthonyG\Documents/./scube_mod.f90:383: undefined reference to `glScalef'
C:\Users\AnthonyG\Documents/./scube_mod.f90:390: undefined reference to `glScalef'
C:\Users\AnthonyG\Documents/./scube_mod.f90:391: undefined reference to `glRotatef'
C:\Users\AnthonyG\Documents/./scube_mod.f90:392: undefined reference to `glRotatef'
C:\Users\AnthonyG\Documents/./scube_mod.f90:393: undefined reference to `glRotatef'
C:\Users\AnthonyG\Documents/./scube_mod.f90:394: undefined reference to `glScalef'
C:\Users\AnthonyG\Documents/./scube_mod.f90:395: undefined reference to `glGetFloatv'
C:\Users\AnthonyG\Documents/./scube_mod.f90:400: undefined reference to `glDepthMask'
C:\Users\AnthonyG\Documents/./scube_mod.f90:402: undefined reference to `glEnable'
C:\Users\AnthonyG\Documents/./scube_mod.f90:404: undefined reference to `glEnable'
C:\Users\AnthonyG\Documents/./scube_mod.f90:412: undefined reference to `glMultMatrixf'
C:\Users\AnthonyG\Documents/./scube_mod.f90:420: undefined reference to `glMultMatrixf'
C:\Users\AnthonyG\Documents/./scube_mod.f90:425: undefined reference to `glDepthMask'
C:\Users\AnthonyG\Documents/./scube_mod.f90:432: undefined reference to `glEnable'
build\scube_mod.o: In function `keyboard':
C:\Users\AnthonyG\Documents/./scube_mod.f90:333: undefined reference to `glEnable'
C:\Users\AnthonyG\Documents/./scube_mod.f90:341: undefined reference to `glEnable'
C:\Users\AnthonyG\Documents/./scube_mod.f90:348: undefined reference to `glFogf'
C:\Users\AnthonyG\Documents/./scube_mod.f90:352: undefined reference to `glFogf'
C:\Users\AnthonyG\Documents/./scube_mod.f90:356: undefined reference to `glFogf'
build\scube_mod.o: In function `_scube_mod_MOD_myshadowmatrix':
C:\Users\AnthonyG\Documents/./scube_mod.f90:306: undefined reference to `glMultMatrixf'
build\scube_mod.o: In function `_scube_mod_MOD_drawcheck':
C:\Users\AnthonyG\Documents/./scube_mod.f90:245: undefined reference to `glGenLists'
C:\Users\AnthonyG\Documents/./scube_mod.f90:247: undefined reference to `glNewList'
C:\Users\AnthonyG\Documents/./scube_mod.f90:250: undefined reference to `glNormal3fv'
C:\Users\AnthonyG\Documents/./scube_mod.f90:269: undefined reference to `glVertex4fv'
C:\Users\AnthonyG\Documents/./scube_mod.f90:270: undefined reference to `glVertex4fv'
C:\Users\AnthonyG\Documents/./scube_mod.f90:271: undefined reference to `glVertex4fv'
C:\Users\AnthonyG\Documents/./scube_mod.f90:272: undefined reference to `glVertex4fv'
C:\Users\AnthonyG\Documents/./scube_mod.f90:282: undefined reference to `glEndList'
C:\Users\AnthonyG\Documents/./scube_mod.f90:287: undefined reference to `glCallList'
build\scube_mod.o: In function `_scube_mod_MOD_drawcube':
C:\Users\AnthonyG\Documents/./scube_mod.f90:221: undefined reference to `glNormal3fv'
C:\Users\AnthonyG\Documents/./scube_mod.f90:223: undefined reference to `glVertex4fv'
C:\Users\AnthonyG\Documents/./scube_mod.f90:224: undefined reference to `glVertex4fv'
C:\Users\AnthonyG\Documents/./scube_mod.f90:225: undefined reference to `glVertex4fv'
C:\Users\AnthonyG\Documents/./scube_mod.f90:226: undefined reference to `glVertex4fv'
build\scube_mod.o: In function `_scube_mod_MOD_setcolor':
C:\Users\AnthonyG\Documents/./scube_mod.f90:157: undefined reference to `glMaterialfv'
C:\Users\AnthonyG\Documents/./scube_mod.f90:160: undefined reference to `glMaterialfv'
C:\Users\AnthonyG\Documents/./scube_mod.f90:166: undefined reference to `glIndexf'
collect2.exe: error: ld returned 1 exit status
Error(E42): Last command making (scube.exe) returned a bad status
Error(E02): Make execution terminated

* Failed *

If anybody has any ideas I could try I would appreciate it. Thanks in advance.

Anthony

Re: Problems compiling when using flibs and opengl

Anthony,

When you're trying to use the flibs filedir package, are you sure to include the proper compiler flags as well?  In Project Options under Compiler Flags, you should have the following in the box labeled Linker:

-lflibs-strings -lflibs=platform -lflibs-filedir

The above libraries are necessary to link against the flibs libraries.  If you do have the appropriate flags, there may be something wrong with the packages themselves.

In the OpenGL example, it seems there may be something wrong with the package flags themselves.  I'm looking into it now.

Jeff Armstrong
Approximatrix, LLC

Re: Problems compiling when using flibs and opengl

A followup on the F03GL package:

It appears that something surrounding linking in the F03GL package is not working properly since moving to GNU Fortran 4.9.0 in 32-bit mode only.  The F03GL's example will compile if you change the project to a 64-bit executable in Project Options.

The 32-bit example fails during linking due to an issue with the calling convention.  For some reason, the compiler and linker can't find and/or link properly with the system OpenGL libraries.  I'll have  a solution shortly.

Jeff Armstrong
Approximatrix, LLC

Re: Problems compiling when using flibs and opengl

A  new version of the F03GL package is now available that fixes linking issues with 32-bit programs.

Jeff Armstrong
Approximatrix, LLC

Re: Problems compiling when using flibs and opengl

Jeff,

thanks very much for your help, opengl is working perfectly now.

I have checked the compiler flags in the linker box and all of the ones you listed for the flibs package are present, and it's still generating the errors listed earlier. Do you know of any other methods for reading directory contents (without using shell commands to create a text file)?

Anthony

Re: Problems compiling when using flibs and opengl

Anthony,

The flibs filedir package should be working.  Let me see if I can figure out why you're receiving the error.  The flibs packages have rather odd ways of handling what types of strings they'll accept, so perhaps our build is not currently working properly.

There are, of course, other ways that would involve your wrapping C functions yourself that call the Windows API (or possibly the C runtime), but let me first check on whether flibs is working properly.

Jeff Armstrong
Approximatrix, LLC

Re: Problems compiling when using flibs and opengl

Anthony,

I've spent some time with flibs, and I was able to replicate your error.  Checking the libraries, though, it was clear that the mentioned functions were indeed present. 

The problem actually turned out to be the order of the library flags.   I occasionally run into this linking issue  when I'm not careful with ordering library flags, and the default flags in the flibs-filedir project is a good example.  If I change the linker flags to:

 -lflibs-filedir -lflibs-platform -lflibs-strings

I don't seem to have any linking errors.  Basically, the m_vfile module relies on functions/modules from both flibs-platform and  flibs-strings.  Therefore, the flags for these libraries have to come after the flag for flibs-filedir.  The provided example, though, did not have this dependency.

Let us know if the above works!  I'll correct the package as well.

Jeff Armstrong
Approximatrix, LLC

Re: Problems compiling when using flibs and opengl

Jeff,

I did indeed have the linker flags in the wrong order, flibs is now working perfectly, thanks again for your help.

Anthony