From: Leek, J. <le...@ll...> - 2013-06-13 08:13:41
|
Hi, this seems like it should have a known easy solution (or at least be a known problem) but I haven't been able to find anything on it. I recently ported a mixed C/C++/Fortran project to Windows using cmake and MinGW. The project has multiple optional libraries, a few of these libraries are written in fortran, and gfortran seems to work fine for compiling them. I usually build statically, but I also support shared library builds. However, one of the libraries is not linking for me shared, although it is fine when built statically. The issue is that the library is not complete by itself, it has a single call back into the main code for some reason. Of course, this call is undefined when the library is built because it's a circular dependency. ld lets that reference be undefined when the library is built statically on Windows, or shared on Linux, or statically on Linux, but when the library is built shared on Windows it fails. Is there anything I can do? CMake generated build line: C:\MinGW\bin\ar.exe cr CMakeFiles\bobyqa.dir/objects.a @CMakeFiles\bobyqa.dir\objects1.rsp C:\MinGW\bin\gfortran.exe -shared -o libbobyqa.dll -Wl,--out-implib,libbobyqa.dll.a -Wl,--major-image-version,0,--minor-image-version,0 -Wl,--whole-archive CMakeFiles\bobyqa.dir/objects.a -Wl,--no-whole-archive Simple hand built line: C:\MinGW\bin\gfortran.exe -shared -o libbobyqa.dll -Wl,--out-implib,libbobyqa.dll.a CMakeFiles\bobyqa.dir\bobyqa.f.obj Both result in: CMakeFiles\bobyqa.dir\bobyqa.f.obj:bobyqa.f:(.text+0x4cf8): undefined referenceto `moobobyqaevalfunc_' c:/mingw/bin/../lib/gcc/mingw32/4.7.2/../../../../mingw32/bin/ld.exe: CMakeFiles\bobyqa.dir\bobyqa.f.obj: bad reloc address 0x20 in section `.eh_frame' collect2.exe: error: ld returned 1 exit status Thanks, Jim |