How to deal with this error when build with Scons?

2019-09-04 09:52发布

问题:

/usr/bin/ld: build/bsp_src/main.o: Undefined first referenced symbol «_ZN5boost6system15system_categoryEv»

//usr/lib/i386-linux-gnu/libboost_system.so.1.54.0: error adding symbols: DSO missing from command line

SConstruct file

I'm trying to build this project https://github.com/TTimo/es_core, and don't have enought expirience with scons

回答1:

Based on the SConstruct file referenced in your question, you're not correctly linking in the boost_system library. You're doing it as follows:

env.Append( CCFLAGS = [ '-g', '-lboost_system', ] )

The CCFLAGS variable should be used to pass compilation flags to the Compiler. The -l flag should be passed to the Linker, not the Compiler. The correct way to do that in SCons is as follows:

env.Append( LIBS = ['boost_system'] )

Notice, I dont add the -l flag, as SCons does that for you in a platform-independent manner.

You may also have to define the path to the library, which is done as follows:

env.Append( LIBPATH = '/put/the/path/here' )

As with the LIBS, you dont need to add the -L flag to LIBPATH, as SCons will add it.

Here is a complete list of the SCons Construction Variables.



标签: boost scons