Menu

Compilation error without 'inline' for sp_version

Nunnsy
2019-09-24
2019-09-24
  • Nunnsy

    Nunnsy - 2019-09-24

    Hi there!

    I've been trying to compile my project which includes "sigpack.h" in multiple files (with appropriate header guards) but was getting the following error:

    XXX@ubuntu:~/XXX$ make
     g++  -g -Wall -pedantic -O2 -std=c++14 -I include -I lib/sigpack -c -o build/XXX.o src/XXX.cpp
     Linking...
     g++  build/*.o -o bin/letitsnow -pthread -larmadillo
    build/XXX.o: In function `sp::sp_version[abi:cxx11]()':
    /XXX/lib/sigpack/base/base.h:205: multiple definition of `sp::sp_version[abi:cxx11]()'
    XXX/lib/sigpack/base/base.h:205: first defined here
    collect2: error: ld returned 1 exit status
    Makefile:15: recipe for target 'bin/letitsnow' failed
    make: *** [bin/letitsnow] Error 1
    

    It seems to be because the function is defined in the header file. To fix this, I changed...
    std::string sp_version(void)
    to...
    inline std::string sp_version(void)
    in base.h.

    Just wondering if this is a bug or if my compilation is incorrect?

    Cheers

     

    Last edit: Nunnsy 2019-09-24
  • Claes Rolen

    Claes Rolen - 2019-09-24

    Hi there! Glad you are using SigPack. This looks like an old bug where the version strings was outside the protective guards. Try version 1.2.5 or newer and see if it solves the problem. BR Claes

     

    Last edit: Claes Rolen 2019-09-24
  • Claes Rolen

    Claes Rolen - 2019-09-24

    EDIT. You are right, definitions should be in a .cpp file. If not (as with header only libs) it should be inlined. Will fix that in the next release 1.2.7!

     
  • Nunnsy

    Nunnsy - 2019-09-24

    Awesome, will update to that now - Thank you! And the library is awesome, it's exactly what I was looking for. I decided to go with Armadillo and then worried about dynamically creating the required filters - alas, your library exists. You've considerably lowered an undergraduate's stress levels for his thesis!

     

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.