Menu

Linking with CERN libraries with Dev c++

ben17
2007-08-07
2012-09-26
  • ben17

    ben17 - 2007-08-07

    Dear All,

    I used to compile my C++ code under linux with g++ (no problem with that). I have now transferred my code under WINDOWS XP and I'm now trying to compile it with DEV C++. My code uses the CERN mathematical libraries which are .lib libraries containing various mathematical functions and routines.

    This is my compile log : all functions that are in the libraries are not recognised ( I have truncated the log since it the same message for all functions).


    Compiler: Default compiler
    Executing g++.exe...
    g++.exe "C:\Documents and Settings\sandapr\Mes documents\RECHERCHE\COLOUR DIPOLES\mesons\nnpz\xsec\master.cpp" -o "C:\Documents and Settings\sandapr\Mes documents\RECHERCHE\COLOUR DIPOLES\mesons\nnpz\xsec\master.exe" -lmathlib -lkernlib -lpacklib -lm -I"C:\Dev-Cpp\include\c++\3.4.2\mingw32" -I"C:\Dev-Cpp\include\c++\3.4.2\backward" -I"C:\Dev-Cpp\include\c++" -I"C:\Dev-Cpp\code" -L"C:\cern\2001\lib"
    C:\DOCUME~1\sandapr\LOCALS~1\Temp/cc67baaa.o(.text+0x306):master.cpp: undefined reference to dbesk1_' C:\DOCUME~1\sandapr\LOCALS~1\Temp/cc67baaa.o(.text+0x421):master.cpp: undefined reference todbesk0_'
    C:\DOCUME~1\sandapr\LOCALS~1\Temp/cc67baaa.o(.text+0x525):master.cpp: undefined reference to dadapt_' C:\DOCUME~1\sandapr\LOCALS~1\Temp/cc67baaa.o(.text+0x734):master.cpp: undefined reference todbesk1_'
    C:\DOCUME~1\sandapr\LOCALS~1\Temp/cc67baaa.o(.text+0x84f):master.cpp: undefined reference to `dbesk0_'


    Pls note:
    1. The CERN libraries are written in F77. (There is a .h file with my code which takes care of declaring the functions in the libraries as external.)

    1. Under Linux with g++ the following command works fine :

    g++ code.cpp -o runcode -L/cern/lib/ -lkernlib -lmathlib -lpacklib -lg2c -lm

    1. With Dev ++, the "-lg2c" is not recognised.

    Hope I have provided adequate info...
    Many thanks for any hints !

    ben17

     
    • Anonymous

      Anonymous - 2007-08-08

      When you specify -lmathlib -lkernlib -lpacklib the linker will look for files called libmathlib.a libkernlib.a and libpacklib.a. The GNU convention is to name libraries libXXX.a.

      These libraries may work if you use there use the library file's full path and name name without the '-l'; there is a button to do just that in the compiler/linker options dialog.

      However, if they were intended for another compiler such as Microsoft or Borland, they may not work at all. If they are export libraries for DLLs in Microsoft format you may be in with a chance, but you might have to upgrade your binutils from www.mingw.org or failing that use the reimp tool to convert them. If they are static libraries, I am not sure if they will work even with a tool-chain upgrade.

      In addition, don't put your projects in "C:\Documents and Settings\sandapr\Mes documents\RECHERCHE\COLOUR DIPOLES" or ANY path containing spaces. Under certain circumstances parts of the tool-chain fail with such paths. The "PLEASE READ BEFORE POSTING A QUESTION" thread is clear on this.

      Clifford

       
    • Wayne Keen

      Wayne Keen - 2007-08-07

      Did you recompile your Fortran libaries under Windows / MinGW before trying to link them?

      Wayne

       
    • ben17

      ben17 - 2007-08-08

      Thanks for the suggestion. I couldn't because I downloaded them as .lib files from the CERN source. I guess I need the source files to be able to recompile. I'll try.
      cheers
      ben17

       
    • Wayne Keen

      Wayne Keen - 2007-08-08

      Don't fall into the trap of assuming that because things are compile with GCC compiler
      components on Linux, that they are automatically completely portable across operating
      systems.

      Wayne

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.