Built Boost 1.75.0 and cannot link my application. I used the same scenario/build and it works for Boost 1.67.0 . I have looked at many similar post but no luck with the answers.
main.o is before the libs and boost_system is last boost library in the boost list.
Any help appreciated.
CentOS 8, g++ (GCC) 8.3.1 20191121 (Red Hat 8.3.1-5)
My build was:
./bootstrap.sh
./b2 -a --threading=multi --link=static
link error:
g++ -DWINUX -pthread -g -O3 -Wall -DNDEBUG -o ../bin/TestApp main.o -L../lib -
L/usr/local/src/boost_1_75_0/stage/lib -Wl,-Bstatic -lboost_date_time -lboost_filesystem -
lboost_thread -lboost_system -Wl,-Bdynamic -lpthread
main.o: In function `boost::asio::detail::scheduler::shutdown()':
/usr/local/include/boost/system/error_code.hpp:461: undefined reference to
`boost::system::system_category()'
main.cpp:
#include <iostream>
#include <boost/shared_ptr.hpp>
#include <boost/asio.hpp>
typedef boost::shared_ptr<boost::asio::io_service> asioPtr_t;
int main(int argc, char* argv[])
{
asioPtr_t io_ = asioPtr_t(new boost::asio::io_service());
std::cout << "Test App: " << __DATE__ << std::endl;
}
Makefile:
ifeq ($(strip $(BOOST_HDRDIR)),)
$(error PLEASE SET BOOST_HDRDIR)
endif
ifeq ($(strip $(BOOST_LIBDIR)),)
$(error PLEASE SET BOOST_LIBDIR)
endif
APP = TestApp
SRCS = $(wildcard *.cpp)
OBJS = $(SRCS:.cpp=.o)
COMPILER = g++
CFLAGS = -DWINUX -pthread -g -O3 -Wall -DNDEBUG
COMPILE = $(COMPILER) $(CFLAGS)
INCLDIRS = -I../ -I$(BOOST_HDRDIR)
LIBDIRS = -L../lib -L$(BOOST_LIBDIR)
LIBS = -Wl,-Bstatic -lboost_date_time -lboost_filesystem \
-lboost_thread -lboost_system \
-Wl,-Bdynamic -lpthread
%.o: %.cpp
$(COMPILE) -c $< $(INCLDIRS) -o $@
$(APP): $(OBJS)
@echo "Linking $(APP)..."
mkdir -p ../bin
$(COMPILE) -o ../bin/$(APP) $(OBJS) $(LIBDIRS) $(LIBS)
test:
$(MAKE) -C UnitTest test
clean:
rm -f $(APP) $(OBJS)