的boost ::在Ubuntu系统链接错误 [英] Boost::system link error on Ubuntu

查看:239
本文介绍了的boost ::在Ubuntu系统链接错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图编译下面的C ++ code实现上下文切换树(下载页面上更多信息

I'm trying to compile the following c++ code that implements Context Tree Switching (More info on the download page):

Zip文件,0.2 MB

这需要一些Boost库。我下载从boost.org最新版本和内置了需要建设按照网站上的说明所有库。我还修改包括在加升压库路径和boost_system存档makefile文件,但我仍然得到一个错误。下面是我使用的生成文件:

which requires some boost libraries. I download the latest version from boost.org and built all libraries that needed building following the instructions on the website. I also modified the makefile included in the archive to add the boost lib path and boost_system, but I still get an error. Here's the makefile i'm using:

PROGRAM = cts
SOURCES = $(wildcard *.cpp)
OBJECTS = $(SOURCES:.cpp=.o)
CFLAGS = -Wall
LDFLAGS = -lboost_program_options -lboost_filesystem -lboost_system

$(PROGRAM): $(OBJECTS) Makefile
    g++ $(CFLAGS) -L/home/users/mnembrini/opt/boost/lib $(LDFLAGS) -o $(PROGRAM) $(OBJECTS)

# Include known dependecies from -MMD
#-include $(OBJECTS:.o=.d)

%.o: %.cpp
    g++ -MMD $(CFLAGS) -I/home/users/mnembrini/opt/boost/include -c $<

clean:
    rm -f $(OBJECTS) *.d

.PHONY: clean

其中,提升在〜/选择/升压(constains lib和包括子目录)。而这里的链接错误:

where boost is in ~/opt/boost (constains lib and include subdir). And here's the linking error:

mnembrini@meem:~/src/cts-v1 $ make
g++ -MMD -Wall -I/home/users/mnembrini/opt/boost/include -c ac.cpp
g++ -MMD -Wall -I/home/users/mnembrini/opt/boost/include -c cts.cpp
cts.cpp: In member function ‘virtual void SwitchingTree::update(bit_t)’:
cts.cpp:402:12: warning: variable ‘snc’ set but not used [-Wunused-but-set-variable]
cts.cpp: In member function ‘virtual double SwitchingTree::prob(bit_t)’:
cts.cpp:432:12: warning: variable ‘snc’ set but not used [-Wunused-but-set-variable]
g++ -MMD -Wall -I/home/users/mnembrini/opt/boost/include -c ctw.cpp
g++ -MMD -Wall -I/home/users/mnembrini/opt/boost/include -c icsilog.cpp
g++ -MMD -Wall -I/home/users/mnembrini/opt/boost/include -c main.cpp
g++ -MMD -Wall -I/home/users/mnembrini/opt/boost/include -c PowFast.cpp
g++ -Wall -L/home/users/mnembrini/opt/boost/lib -lboost_program_options -lboost_filesystem -lboost_system -o cts ac.o cts.o ctw.o icsilog.o main.o PowFast.o
cts.o: In function `__static_initialization_and_destruction_0(int, int)':
cts.cpp:(.text+0x1743): undefined reference to `boost::system::generic_category()'
cts.cpp:(.text+0x174f): undefined reference to `boost::system::generic_category()'
cts.cpp:(.text+0x175b): undefined reference to `boost::system::system_category()'
ctw.o: In function `__static_initialization_and_destruction_0(int, int)':
ctw.cpp:(.text+0xfcf): undefined reference to `boost::system::generic_category()'
ctw.cpp:(.text+0xfdb): undefined reference to `boost::system::generic_category()'
ctw.cpp:(.text+0xfe7): undefined reference to `boost::system::system_category()'
main.o: In function `showHelp()':
main.cpp:(.text+0x1c): undefined reference to `boost::program_options::operator<<(std::basic_ostream<char, std::char_traits<char> >&, boost::program_options::options_description const&)'
main.o: In function `initOptions(int, char**, boost::program_options::variables_map&)':
main.cpp:(.text+0x10f): undefined reference to `boost::program_options::options_description::add_options()'
main.cpp:(.text+0x129): undefined reference to `boost::program_options::options_description_easy_init::operator()(char const*, char const*)'
main.cpp:(.text+0x13e): undefined reference to `boost::program_options::options_description_easy_init::operator()(char const*, boost::program_options::value_semantic const*, char const*)'
main.cpp:(.text+0x153): undefined reference to `boost::program_options::options_description_easy_init::operator()(char const*, boost::program_options::value_semantic const*, char const*)'
main.cpp:(.text+0x166): undefined reference to `boost::program_options::options_description_easy_init::operator()(char const*, boost::program_options::value_semantic const*, char const*)'
main.cpp:(.text+0x1d6): undefined reference to `boost::program_options::store(boost::program_options::basic_parsed_options<char> const&, boost::program_options::variables_map&, bool)'
main.cpp:(.text+0x200): undefined reference to `boost::program_options::notify(boost::program_options::variables_map&)'
main.o: In function `__static_initialization_and_destruction_0(int, int)':
main.cpp:(.text+0x1f13): undefined reference to `boost::system::generic_category()'
main.cpp:(.text+0x1f1f): undefined reference to `boost::system::generic_category()'
[snip (2-3 screens like above)]
collect2: ld returned 1 exit status
make: *** [cts] Error 1

我用gcc 4.6.3在Ubuntu 12.04 64位。

I'm using Gcc 4.6.3 on Ubuntu 12.04 64bit.

推荐答案

将所有的库在命令行中的所有目标文件后。顺序很重要,在这里,在一些其他操作系统不同。

Place all the libraries after all the object files within the command line. The order is important here, unlike on some other operating systems.

这篇关于的boost ::在Ubuntu系统链接错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆