你好我想鏈接升壓使用線程庫,但似乎無法得到它建立。鏈接升壓(自制)Mac C++
我安裝了升壓用自制(MAC包安裝),它是在/usr/local/Cellar/boost/1.50.0
目錄。
我的主要文件是很簡單的,現在......
#include <iostream>
#include <boost/thread.hpp>
我make文件是這樣的:
CC = g++
BASE_FLAGS = -m32 -wAll
# INCLUDE BASE DIRECTORY AND BOOST DIRECTORY FOR HEADERS
LDFLAGS = -I/usr/local/Cellar/boost/1.50.0/include -I/opt/local/include
# INCLUDE BASE DIRECTORY AND BOOST DIRECTORY FOR LIB FILES
LLIBFLAGS = -L/usr/local/Cellar/boost/1.50.0/
# SPECIFIY LINK OPTIONS
LINKFLAGS = -l boost_thread-mt -lboost_system
# FINAL FLAGS -- TO BE USED THROUGHOUT
FLAGS = $(BASE_FLAGS) $(LLIBFLAGS) $(LDFLAGS) $(LINKFLAGS)
# NOTE FOR BOOST -- YOU ONLY NEED TO INCLUDE THE PATH BECAUSE IT ONLY INSTALLS HEADER FILES
main: main.cpp
$(CC) $(FLAGS) -o main.out main.cpp
當我運行它,我得到一個庫未找到boost_system 。如果我參加了boost_system,然後我得到看起來像這樣的錯誤:
ld: warning: ignoring file /usr/local/lib/libboost_thread-mt.dylib, file was built for unsupported file format (0xcf 0xfa 0xed 0xfe 0x 7 0x 0 0x 0 0x 1 0x 3 0x 0 0x 0 0x 0 0x 6 0x 0 0x 0 0x 0) which is not the architecture being linked (i386): /usr/local/lib/libboost_thread-mt.dylib
Undefined symbols for architecture i386:
"boost::system::system_category()", referenced from:
__static_initialization_and_destruction_0(int, int)in ccKwJWzr.o
"boost::system::generic_category()", referenced from:
__static_initialization_and_destruction_0(int, int)in ccKwJWzr.o
ld: symbol(s) not found for architecture i386
collect2: ld returned 1 exit status
make: *** [main] Error 1
你爲什麼要鏈接一個文件,'-mt'後綴,一個沒有?嘗試'-lboost_thread -lboost_system'或'-lboost_thread-MT -lboost_system-mt' –
打招呼,當我剛剛聯繫-lboost_thread它給了我LD'LD的錯誤:庫沒有找到-lboost_thread collect2:LD返回1退出狀態' – JonMorehouse
將兩個「-mt」加在一起會發生什麼? –