Hi all,

I have been using Boost.Test for about a month now. Big fan so far, except for the atrocious compilation times, hence why I am moving toward using the shared library.

using b2 to build and install Boost.Test's libs was simple enough, though after making the noted changes here:
https://www.boost.org/doc/libs/1_72_0/libs/test/doc/html/boost_test/adv_scenarios/shared_lib_customizations/entry_point.html

to customize the module's entry point, g++ cannot find the main executable:

Undefined symbols for architecture x86_64:

  "_main", referenced from:

     implicit entry/start for main executable

ld: symbol(s) not found for architecture x86_64

clang: error: linker command failed with exit code 1 (use -v to see invocation)

make: *** [Guest_T] Error 1


I tried digging through the docs for more information, but I came up short.

For more context, I have written unit tests for each of my classes. For example, if my classes were A, B, and C, I would have A_T.cpp, B_T.cpp, and C_T.cpp for unit tests.

- Should each of the unit tests have their own main() function? (I would think not..)

- If not, how do I instruct g++ to first compile main.cpp before attempting to compile anything else?

If you are curious, here are the contents of my Makefile:

PROG := main

CC := g++

SDIR := ../src

PKG_DIRS := $(shell ls $(SDIR))

CXXFLAGS = -v -Wall -std=c++11 -I$(SDIR_TEST) \

$(addprefix -I$(SDIR)/,$(PKG_DIRS)) -I$(BOOST_ROOT) \

-L$(BOOST_LIBS) -Wl,-rpath,$(BOOST_LIBS) -lboost_unit_test_framework

ODIR_TEST = ./bin

SDIR_TEST = ./src

OUTDIR = ./execs

ODIR = ../sim/bin


TEST_EXEC_NAMES = $(notdir $(basename $(wildcard $(SDIR_TEST)/*.cpp)))


$(OUTDIR)/$(PROG) : $(SDIR_TEST)/main.cpp

        $(CC) $(CXXFLAGS) -o $@ $<


$(OUTDIR)/$(PROG) : $(TEST_EXEC_NAMES)

        $(CC) $(CXXFLAGS) -o $@ $^


% : $(SDIR_TEST)/%.cpp

        $(CC) $(CXXFLAGS) -o $(OUTDIR)/$@ $^


From what I can tell, g++ is failing to find the main the executable because it is attempting to compile one of my unit test files first. This may or may not be the case; either way, I would appreciate some help or direction as to what I should read to learn more about this.

Let me know if you need more info.

Thanks in advance.

- AJ