c++gcclinkerpantheios

Linking issues with pantheios - undefined reference pantheios_init


I have already read pretty much all of the posts relating to this. I do link to the core library twice, as suggested in so many places. I just can't figure out what the issue is. Here the error:

main.o: In function `pantheios_initialiser::pantheios_initialiser()':
/home/awishformore/code/pantheios/include/pantheios/./internal/initialiser.hpp:119: undefined reference to `pantheios_init'
/home/awishformore/code/pantheios/include/pantheios/./internal/initialiser.hpp:121: undefined reference to `pantheios_exitProcess'
main.o: In function `pantheios_initialiser::~pantheios_initialiser()':
/home/awishformore/code/pantheios/include/pantheios/./internal/initialiser.hpp:133: undefined reference to `pantheios_uninit'

This is the line my makefile generates for linking:

g++ -Wall -g -I/home/awishformore/code/stlsoft/include -I/home/awishformore/code/pantheios/include -I/home/awishformore/code/boost_1_54_0 -I/home/awishformore/code/mysql/include -L/home/awishformore/code/pantheios/lib -L/home/awishformore/code/mysql/lib -L/home/awishformore/code/boost_1_54_0/lib -lpantheios.1.core.gcc46.file64bit.mt -lpantheios.1.fe.simple.gcc46.file64bit.mt -lpantheios.1.be.fprintf.gcc46.file64bit.mt -lpantheios.1.bec.fprintf.gcc46.file64bit.mt -lpantheios.1.core.gcc46.file64bit.mt -lpantheios.1.util.gcc46.file64bit.mt main.o Database.o -o engine

I really don't see anything wrong with it?


Solution

  • After hours and hours of wasting my time on this, I finally found the answer in this small, inconspicuous post.

    Due to the way pantheios is built and the way gcc works, the libraries need to appear behind the object files in the linking command, as follows:

    g++ <compiler flags> <include paths> main.o <other objects> <library paths> <libraries> -o main
    

    When I tried that, the error changed to undefined pthread references, which was easily solved by linking against the pthread library, too.