致命错误:找不到'boost / test / unit_test.hpp'文件

时间:2019-02-23 20:55:24

标签: c++ boost makefile boost-test

我需要将Boost.Test合并到macOS上的C ++程序中。在这样做之前,我首先需要使用示例来测试Makefile:https://github.com/jsankey/boost.test-examples包含的makefile无法正常工作,因此我对其进行了修改。

TARGETS=main hello suites fixtures assertions
INC=-I/usr/local/boost/include
LDFLAGS=-L/usr/local/lib -lboost_unit_test_framework
all: $(TARGETS)

test: $(TARGETS) $(addprefix run-,$(TARGETS))

main.o: main.cpp
    $(CXX) $< $(INC) -c
hello.o: hello.cpp
    $(CXX) $< $(INC) -c
suites.o: suites.cpp
    $(CXX) $< $(INC) -c
fixtures.o: fixtures.cpp
    $(CXX) $< $(INC) -c
assertions.o: assertions.cpp
    $(CXX) $< $(INC) -c
main: main.o
    $(CXX) $^ $(LDFLAGS) -o $@
hello: hello.o
    $(CXX) $^ $(LDFLAGS) -o $@
suites: suites.o
    $(CXX) $^ $(LDFLAGS) -o $@
fixtures: fixtures.o
    $(CXX) $^ $(LDFLAGS) -o $@
assertions: assertions.o
    $(CXX) $^ $(LDFLAGS) -o $@

run-%: %
    -./$^ --output_format=XML --log_level=test_suite > $(^)-report.xml

clean:
     rm $(TARGETS) *-report.xml

已编辑:现在,编译效果很好。另一方面,链接会导致错误,即以下错误:

ld:警告:忽略文件/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/lib/libSystem.tbd,该文件是为不支持的文件格式构建的( 0x2D 0x2D 0x2D 0x20 0x21 0x74 0x61 0x70 0x69 0x2D 0x74 0x62 0x64 0x2D 0x76 0x33)并非链接的架构(x86_64):/Applications/Xcode.app/Contents/Developer/Platforms/MacOSXSD/platforms/MacOSX.platform/ .sdk / usr / lib / libSystem.tbd 架构x86_64的未定义符号: “ __Unwind_Resume”,引用自: hello.o中的boost :: unit_test :: singleton :: instance()       在hello.o中进行boost :: unit_test :: make_test_case(boost :: function const&,boost :: unit_test :: basic_cstring,boost :: unit_test :: basic_cstring,unsigned long)       hello.o中的UniverseInOrder_invoker()       hello.o中的boost :: unit_test :: singleton :: instance()       hello.o中的UniverseInOrder :: test_method()       hello.o中的boost :: unit_test :: lazy_ostream :: instance()       hello.o中的boost :: basic_wrap_stringstream :: str()       ...   “ ___bzero”,引用自:       hello.o中的UniverseInOrder_invoker()   “ ___cxa_atexit”,引用自:

hello.o中的boost :: unit_test :: singleton :: instance()       hello.o中的boost :: unit_test :: singleton :: instance()       hello.o中的boost :: unit_test :: lazy_ostream :: instance()   “ _memcpy”,引用自:       在hello.o中的std :: __ 1 :: char_traits :: copy(char *,char const *,unsigned long)   “ _memset”,引用自:       std :: __ 1 :: ostreambuf_iterator> std :: __ 1 :: __ pad_and_output>(std :: __ 1 :: ostreambuf_iterator>,char const *,char const *,char const *,std :: ___ 1 :: ios_base&,char) .o       在hello.o中的std :: __ 1 :: char_traits :: assign(char *,unsigned long,char)       hello.o中的boost :: basic_wrap_stringstream :: basic_wrap_stringstream()       std :: __ 1 :: basic_stringbuf,std :: __ 1 :: allocator> :: seekoff(long long,std :: __ 1 :: ios_base :: seekdir,unsigned int)在hello.o中       hello.o中的std :: __ 1 :: basic_stringbuf,std :: __ 1 :: allocator> :: str()const       std :: __ 1 :: basic_ostream>&boost :: unit_test :: operator <<,char const>(std :: __ 1 :: basic_ostream>&,boost :: unit_test :: basic_cstring const&)在hello.o中       “ _strcmp”,引用自:

hello.o中的

boost :: typeindex :: stl_type_index :: equal(boost :: typeindex :: stl_type_index const&)const       “ _strlen”,引用自:           在hello.o中的std :: __ 1 :: char_traits :: length(char const *)     ld:找不到架构x86_64的符号     clang-4.0:错误:链接器命令失败,退出代码为1(使用-v查看调用)     make:*** [Makefile:21:hello]错误1

0 个答案:

没有答案