Re: [Boost-users] Boost-users Digest, Vol 5327, Issue 1
Okay, I have almost completely fixed my problems.
I just spent the past hour:
- creating test case headers for each test translation unit (don't worry, I
sped this up using a macro hehe)
- inserting static test case method declarations privately in said headers
- eliminating method redefinitions by toying with test translation unit
#includes
I am ALMOST there. Going to start a new issue, as my current problem is now
vastly different from what is stated in the subject line. Consider the
original problem for this issue SOLVED.
Cheers!
On Fri, Feb 28, 2020 at 9:04 PM
Send Boost-users mailing list submissions to boost-users@lists.boost.org
To subscribe or unsubscribe via the World Wide Web, visit https://lists.boost.org/mailman/listinfo.cgi/boost-users or, via email, send a message with subject or body 'help' to boost-users-request@lists.boost.org
You can reach the person managing the list at boost-users-owner@lists.boost.org
When replying, please edit your Subject line so it is more specific than "Re: Contents of Boost-users digest..."
Today's Topics:
1. [Boost.Test] linking with shared lib (cannot find main) (Andrew McFarlane) 2. Re: [Boost.Test] linking with shared lib (cannot find main) (Andrew McFarlane)
----------------------------------------------------------------------
Message: 1 Date: Fri, 28 Feb 2020 18:50:38 -0800 From: Andrew McFarlane
To: Boost users list Subject: [Boost-users] [Boost.Test] linking with shared lib (cannot find main) Message-ID: < CAG90r9S4rCVPXACn5o6zG9xZQe9oucr7zR6PYHKHqgdUGGJ1Bw@mail.gmail.com> Content-Type: text/plain; charset="utf-8" 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_scen...
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
participants (1)
-
Andrew McFarlane