Xin chào, tôi đang cố gắng liên kết với việc tăng cường sử dụng thư viện luồng, nhưng dường như không thể làm cho nó được xây dựng.Liên kết với Boost (Homebrew) Mac C++
Tôi đã cài đặt tăng với HomeBrew (trình cài đặt gói mac) và nó nằm trong thư mục /usr/local/Cellar/boost/1.50.0
.
tập tin chính của tôi là rất đơn giản ngay bây giờ ...
#include <iostream>
#include <boost/thread.hpp>
làm cho tập tin của tôi là như thế này:
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
Và khi tôi chạy này, tôi nhận được một thư viện không tìm thấy cho boost_system . Nếu tôi đưa ra các boost_system, sau đó tôi nhận được một lỗi mà trông như thế này:
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
Tại sao bạn kết nối một tập tin với 'suffix -mt' và một không? Hãy thử '-lboost_thread -lboost_system' hoặc' -lboost_thread-mt -lboost_system-mt' –
hello, khi tôi liên kết với chỉ -lboost_thread nó cho tôi một lỗi của ld 'ld: thư viện không tìm thấy cho -lboost_thread collect2: ld trả về 1 exit status' – JonMorehouse
Điều gì sẽ xảy ra khi bạn thêm '-mt' vào cả hai? –