undefined reference error in Ubuntu

Help
2014-01-30
2014-01-30
  • Ayush Shrestha

    Ayush Shrestha - 2014-01-30

    I'm trying to build a simple app to load a 3D model and display it in Ubuntu 13.04. This is how my code looks like:

    bool importFromFile(const char* pFile){
        const aiScene* scene = aiImportFile(pFile,aiProcess_Triangulate);
        if( !scene)
        {
            printf("%s\n",aiGetErrorString());
            return false;
        }
        initScene(scene);
        aiReleaseImport( scene);
        return true;
    }
    

    my compile script looks like this:

    export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
    g++ -Wall -L/usr/lib/nvidia-304/ filename.cpp -lglut -lGLEW -lGL
    

    The nvidia-304 is to link the opengl provided by nvidia.

    I get the following message:

    /tmp/ccjRvb5R.o: In function `importFromFile(char const*)':
    draw_assimp_obj.cc:(.text+0x383): undefined reference to `aiImportFile'
    draw_assimp_obj.cc:(.text+0x393): undefined reference to `aiGetErrorString'
    draw_assimp_obj.cc:(.text+0x3ba): undefined reference to `aiReleaseImport'
    collect2: error: ld returned 1 exit status
    

    I compiled and installed the assimp--3.0.1270 version using

    cmake -G 'Unix Makefiles'
    make
    sudo make install
    sudo ldconfig
    

    I didnt have any problems compiling it.

    Am I missing something here? Do I need to explicitly link the libraries - if yes then how do i do that? Most of the forums just talk about Visual Studio but i'm using linux commandline. Any help would be greatly appreciated. Thank you so much.

     
  • Kim Kulling

    Kim Kulling - 2014-01-30

    Hi,

    which version have you used? The version from github, the latest debia package or ... ? And can you show us the output from ldconfig?

    Kimmi

     
  • Ayush Shrestha

    Ayush Shrestha - 2014-01-30

    Thanks for replying Kimmi. ldconfig doesn't give any errors. I did find a way to compile it though. I dont know whether this is the perfect way but it got my job done.

    g++ -Wall -L/usr/lib/nvidia-304/ <filename.cpp> -lglut -lGLEW -lGL /usr/lib/libassimp.so
    
     
  • Kim Kulling

    Kim Kulling - 2014-01-30

    Hi,

    normally ldconfig should help you to get the place, where the assimp-lib is placed. I will check this also.

    Kimmi

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks