Bonjour J'essaye de lier avec boost pour utiliser la librairie de threads, mais je n'arrive pas à la construire.Lien avec Boost (Homebrew) Mac C++
J'ai installé boost avec HomeBrew (programme d'installation de mac) et il est dans le répertoire /usr/local/Cellar/boost/1.50.0
.
Mon fichier principal est très simple en ce moment ...
#include <iostream>
#include <boost/thread.hpp>
Mon fichier makefile est comme ceci:
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
Et quand je lance cela, je reçois une bibliothèque introuvable pour boost_system . Si je prends le boost_system, je reçois une erreur qui ressemble à ceci:
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
Pourquoi vous liez un fichier avec le suffixe '-mt' et un sans? Essayez '-lboost_thread -lboost_system' ou' -lboost_thread-mt -lboost_system-mt' –
bonjour, quand je lie avec juste -lboost_thread cela me donne une erreur de ld 'ld: bibliothèque introuvable pour -lboost_thread collect2: ld retourné 1 exit status' – JonMorehouse
Que se passe-t-il lorsque vous ajoutez '-mt' aux deux? –