std::terminate() linker error on a small clang project - c++

I'm getting the following error on a project that links with clang (verbose output):
clang++ `/usr/local/Cellar/llvm/3.6.2/bin/llvm-config --cxxflags --ldflags --libs --system-libs` -lc++ -fno-rtti -o gen -lclangFrontendTool -lclangFrontend -lclangDriver -lclangSerialization -lclangCodeGen -lclangParse -lclangSema -lclangStaticAnalyzerFrontend -lclangStaticAnalyzerCheckers -lclangStaticAnalyzerCore -lclangAnalysis -lclangARCMigrate -lclangRewriteFrontend -lclangEdit -lclangAST -lclangLex -lclangBasic -I /usr/local/Cellar/llvm/3.6.2/include src/main.cpp -v
Apple LLVM version 7.0.2 (clang-700.1.81)
Target: x86_64-apple-darwin14.5.0
Thread model: posix
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang" -cc1 -triple x86_64-apple-macosx10.10.0 -Wdeprecated-objc-isa-usage -Werror=deprecated-objc-isa-usage -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -main-file-name main.cpp -mrelocation-model pic -pic-level 2 -mthread-model posix -mdisable-fp-elim -masm-verbose -munwind-tables -target-cpu core2 -target-linker-version 253.9 -v -dwarf-column-info -resource-dir /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/7.0.2 -D __STDC_CONSTANT_MACROS -D __STDC_FORMAT_MACROS -D __STDC_LIMIT_MACROS -I /usr/local/Cellar/llvm/3.6.2/include -I /usr/local/Cellar/llvm/3.6.2/include -stdlib=libc++ -Wall -W -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -Wno-long-long -Wcovered-switch-default -Wnon-virtual-dtor -pedantic -std=c++11 -fdeprecated-macro -fdebug-compilation-dir /Users/samvv/Projects/ffi-enhanced/xfi-gen -ferror-limit 19 -fmessage-length 142 -fvisibility-inlines-hidden -stack-protector 1 -mstackrealign -fblocks -fno-rtti -fobjc-runtime=macosx-10.10.0 -fencode-extended-block-signature -fcxx-exceptions -fexceptions -fmax-type-align=16 -fdiagnostics-show-option -fcolor-diagnostics -o /var/folders/9g/8c11l8090p524v5r7873yghc0000gn/T/main-918e82.o -x c++ src/main.cpp
clang -cc1 version 7.0.2 based upon LLVM 3.7.0svn default target x86_64-apple-darwin14.5.0
ignoring nonexistent directory "/usr/include/c++/v1"
ignoring duplicate directory "/usr/local/Cellar/llvm/3.6.2/include"
> #include "..." search starts here:
> #include <...> search starts here:
/usr/local/Cellar/llvm/3.6.2/include
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1
/usr/local/include
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/7.0.2/include
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include
/usr/include
/System/Library/Frameworks (framework directory)
/Library/Frameworks (framework directory)
End of search list.
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld" -demangle -dynamic -arch x86_64 -macosx_version_min 10.10.0 -o gen -L/usr/local/Cellar/llvm/3.6.2/lib -search_paths_first -headerpad_max_install_names -lLLVMLTO -lLLVMObjCARCOpts -lLLVMLinker -lLLVMBitWriter -lLLVMIRReader -lLLVMAsmParser -lLLVMXCoreDisassembler -lLLVMXCoreCodeGen -lLLVMXCoreDesc -lLLVMXCoreInfo -lLLVMXCoreAsmPrinter -lLLVMSystemZDisassembler -lLLVMSystemZCodeGen -lLLVMSystemZAsmParser -lLLVMSystemZDesc -lLLVMSystemZInfo -lLLVMSystemZAsmPrinter -lLLVMSparcDisassembler -lLLVMSparcCodeGen -lLLVMSparcAsmParser -lLLVMSparcDesc -lLLVMSparcInfo -lLLVMSparcAsmPrinter -lLLVMR600CodeGen -lLLVMipo -lLLVMVectorize -lLLVMR600AsmParser -lLLVMR600Desc -lLLVMR600Info -lLLVMR600AsmPrinter -lLLVMPowerPCDisassembler -lLLVMPowerPCCodeGen -lLLVMPowerPCAsmParser -lLLVMPowerPCDesc -lLLVMPowerPCInfo -lLLVMPowerPCAsmPrinter -lLLVMNVPTXCodeGen -lLLVMNVPTXDesc -lLLVMNVPTXInfo -lLLVMNVPTXAsmPrinter -lLLVMMSP430CodeGen -lLLVMMSP430Desc -lLLVMMSP430Info -lLLVMMSP430AsmPrinter -lLLVMMipsDisassembler -lLLVMMipsCodeGen -lLLVMMipsAsmParser -lLLVMMipsDesc -lLLVMMipsInfo -lLLVMMipsAsmPrinter -lLLVMHexagonDisassembler -lLLVMHexagonCodeGen -lLLVMHexagonDesc -lLLVMHexagonInfo -lLLVMCppBackendCodeGen -lLLVMCppBackendInfo -lLLVMARMDisassembler -lLLVMARMCodeGen -lLLVMARMAsmParser -lLLVMARMDesc -lLLVMARMInfo -lLLVMARMAsmPrinter -lLLVMAArch64Disassembler -lLLVMAArch64CodeGen -lLLVMAArch64AsmParser -lLLVMAArch64Desc -lLLVMAArch64Info -lLLVMAArch64AsmPrinter -lLLVMAArch64Utils -lLLVMTableGen -lLLVMDebugInfo -lLLVMOption -lLLVMX86Disassembler -lLLVMX86AsmParser -lLLVMX86CodeGen -lLLVMSelectionDAG -lLLVMAsmPrinter -lLLVMX86Desc -lLLVMMCDisassembler -lLLVMX86Info -lLLVMX86AsmPrinter -lLLVMX86Utils -lLLVMMCJIT -lLLVMLineEditor -lLLVMInstrumentation -lLLVMInterpreter -lLLVMExecutionEngine -lLLVMRuntimeDyld -lLLVMCodeGen -lLLVMScalarOpts -lLLVMProfileData -lLLVMObject -lLLVMMCParser -lLLVMBitReader -lLLVMInstCombine -lLLVMTransformUtils -lLLVMipa -lLLVMAnalysis -lLLVMTarget -lLLVMMC -lLLVMCore -lLLVMSupport -lcurses -lpthread -lz -lm -lc++ -lclangFrontendTool -lclangFrontend -lclangDriver -lclangSerialization -lclangCodeGen -lclangParse -lclangSema -lclangStaticAnalyzerFrontend -lclangStaticAnalyzerCheckers -lclangStaticAnalyzerCore -lclangAnalysis -lclangARCMigrate -lclangRewriteFrontend -lclangEdit -lclangAST -lclangLex -lclangBasic /var/folders/9g/8c11l8090p524v5r7873yghc0000gn/T/main-918e82.o -lc++ -lSystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/7.0.2/lib/darwin/libclang_rt.osx.a
Undefined symbols for architecture x86_64:
"std::terminate()", referenced from:
___clang_call_terminate in main-918e82.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [all] Error 1
According to this question, linking with -lc++ should fix the issue, but in my case it doesn't. I've managed to reduce the issue down to this flag, which is added by llvm-config --ldflags:
-L/usr/local/Cellar/llvm/3.6.2/lib
Any idea why this flag is causing the error and how to fix it?

I found the problem: I was linking to non-default stdlibs using -L/usr/local/opt/llvm/lib/. By prepending -L/usr/lib, it made sure that OS X's default stdlib goes above the homebrewn version.

Related

C++20 standard library compile error for module on macOS

Here are my test code and build scripts.
testmodule.cpp
#include <iostream>
export module testmodule;
export int add(int a, int b)
{
return a + b;
}
main.cpp
#include <iostream>
import testmodule;
using namespace std;
int main() {
cout << "Test Modules" << endl;
cout << "add 1 and 2 is " << add(1,2) << endl;
}
build.sh
rm *.o
rm *.pcm
clang++ -fmodules-ts -Wall -v -c -ferror-limit=1 -Xclang -emit-module-interface testmodule.cpp -o testmodule.pcm
clang++ -fmodules-ts -Wall -v -c -ferror-limit=1 -fprebuilt-module-path=. main.cpp -o main.o
clang++ -fmodules-ts -o main main.o *.pcm
When I run the build.sh, I got the following compile errors:
Apple clang version 14.0.0 (clang-1400.0.29.102)
Target: x86_64-apple-darwin21.6.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
"/Library/Developer/CommandLineTools/usr/bin/clang" -cc1 -triple x86_64-apple-macosx12.0.0 -Wundef-prefix=TARGET_OS_ -Wdeprecated-objc-isa-usage -Werror=deprecated-objc-isa-usage -Werror=implicit-function-declaration -emit-obj -mrelax-all --mrelax-relocations -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name main.cpp -mrelocation-model pic -pic-level 2 -mframe-pointer=all -fno-strict-return -fno-rounding-math -funwind-tables=2 -target-sdk-version=12.3 -fvisibility-inlines-hidden-static-local-var -target-cpu penryn -tune-cpu generic -debugger-tuning=lldb -target-linker-version 819.6 -v -resource-dir /Library/Developer/CommandLineTools/usr/lib/clang/14.0.0 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/usr/local/include -stdlib=libc++ -internal-isystem /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1 -internal-isystem /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/local/include -internal-isystem /Library/Developer/CommandLineTools/usr/lib/clang/14.0.0/include -internal-externc-isystem /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include -internal-externc-isystem /Library/Developer/CommandLineTools/usr/include -Wall -Wno-reorder-init-list -Wno-implicit-int-float-conversion -Wno-c99-designator -Wno-final-dtor-non-final-class -Wno-extra-semi-stmt -Wno-misleading-indentation -Wno-quoted-include-in-framework-header -Wno-implicit-fallthrough -Wno-enum-enum-conversion -Wno-enum-float-conversion -Wno-elaborated-enum-base -Wno-reserved-identifier -Wno-gnu-folding-constant -Wno-cast-function-type -Wno-bitwise-instead-of-logical -fdeprecated-macro -fdebug-compilation-dir=/Users/bf/Workspaces/C-plus-plus-Playground/validateC++20 -ferror-limit 1 -stack-protector 1 -fstack-check -mdarwin-stkchk-strong-link -fblocks -fencode-extended-block-signature -fregister-global-dtors-with-atexit -fgnuc-version=4.2.1 -fno-cxx-modules -fmodules-ts -fno-implicit-modules -fprebuilt-module-path=. -fcxx-exceptions -fexceptions -fmax-type-align=16 -fcommon -fcolor-diagnostics -clang-vendor-feature=+messageToSelfInClassMethodIdReturnType -clang-vendor-feature=+disableInferNewAvailabilityFromInit -clang-vendor-feature=+disableNonDependentMemberExprInCurrentInstantiation -fno-odr-hash-protocols -clang-vendor-feature=+enableAggressiveVLAFolding -clang-vendor-feature=+revert09abecef7bbf -clang-vendor-feature=+thisNoAlignAttr -clang-vendor-feature=+thisNoNullAttr -mllvm -disable-aligned-alloc-awareness=1 -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o main.o -x c++ main.cpp
clang -cc1 version 14.0.0 (clang-1400.0.29.102) default target x86_64-apple-darwin21.6.0
ignoring nonexistent directory "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/local/include"
ignoring nonexistent directory "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/Library/Frameworks"
#include "..." search starts here:
#include <...> search starts here:
/usr/local/include
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1
/Library/Developer/CommandLineTools/usr/lib/clang/14.0.0/include
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include
/Library/Developer/CommandLineTools/usr/include
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks (framework directory)
End of search list.
In module 'testmodule' imported from main.cpp:3:
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/ostream:216:20: error: 'std::basic_ostream<char>::operator<<' from module 'testmodule.<global>' is not present in definition of 'std::ostream' provided earlier
basic_ostream& operator<<(nullptr_t)
^
If I comment out the line #1 in testmodule.cpp and run build.sh, I'll get a main binary as expected.
% ./main
Test Modules
add 1 and 2 is 3
It seems that I cannot include std libraries in both main.cpp and testmodule.cpp.
Any idea where I can start to look into this?
[Update 2022-10-18]
With Remy's suggestion, I tried import <iostream>; in testmodule.cpp, and got the following errors,
Apple clang version 14.0.0 (clang-1400.0.29.102)
Target: x86_64-apple-darwin21.6.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
"/Library/Developer/CommandLineTools/usr/bin/clang" -cc1 -triple x86_64-apple-macosx12.0.0 -Wundef-prefix=TARGET_OS_ -Wdeprecated-objc-isa-usage -Werror=deprecated-objc-isa-usage -Werror=implicit-function-declaration -emit-obj -mrelax-all --mrelax-relocations -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name testmodule.cpp -mrelocation-model pic -pic-level 2 -mframe-pointer=all -fno-strict-return -fno-rounding-math -funwind-tables=2 -target-sdk-version=12.3 -fvisibility-inlines-hidden-static-local-var -target-cpu penryn -tune-cpu generic -debugger-tuning=lldb -target-linker-version 819.6 -v -resource-dir /Library/Developer/CommandLineTools/usr/lib/clang/14.0.0 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/usr/local/include -stdlib=libc++ -internal-isystem /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1 -internal-isystem /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/local/include -internal-isystem /Library/Developer/CommandLineTools/usr/lib/clang/14.0.0/include -internal-externc-isystem /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include -internal-externc-isystem /Library/Developer/CommandLineTools/usr/include -Wall -Wno-reorder-init-list -Wno-implicit-int-float-conversion -Wno-c99-designator -Wno-final-dtor-non-final-class -Wno-extra-semi-stmt -Wno-misleading-indentation -Wno-quoted-include-in-framework-header -Wno-implicit-fallthrough -Wno-enum-enum-conversion -Wno-enum-float-conversion -Wno-elaborated-enum-base -Wno-reserved-identifier -Wno-gnu-folding-constant -Wno-cast-function-type -Wno-bitwise-instead-of-logical -fdeprecated-macro -fdebug-compilation-dir=/Users/bf/Workspaces/C-plus-plus-Playground/validateC++20 -ferror-limit 1 -stack-protector 1 -fstack-check -mdarwin-stkchk-strong-link -fblocks -fencode-extended-block-signature -fregister-global-dtors-with-atexit -fgnuc-version=4.2.1 -fno-cxx-modules -fmodules-ts -fno-implicit-modules -fcxx-exceptions -fexceptions -fmax-type-align=16 -fcommon -fcolor-diagnostics -emit-module-interface -clang-vendor-feature=+messageToSelfInClassMethodIdReturnType -clang-vendor-feature=+disableInferNewAvailabilityFromInit -clang-vendor-feature=+disableNonDependentMemberExprInCurrentInstantiation -fno-odr-hash-protocols -clang-vendor-feature=+enableAggressiveVLAFolding -clang-vendor-feature=+revert09abecef7bbf -clang-vendor-feature=+thisNoAlignAttr -clang-vendor-feature=+thisNoNullAttr -mllvm -disable-aligned-alloc-awareness=1 -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o testmodule.pcm -x c++ testmodule.cpp
clang -cc1 version 14.0.0 (clang-1400.0.29.102) default target x86_64-apple-darwin21.6.0
ignoring nonexistent directory "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/local/include"
ignoring nonexistent directory "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/Library/Frameworks"
#include "..." search starts here:
#include <...> search starts here:
/usr/local/include
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1
/Library/Developer/CommandLineTools/usr/lib/clang/14.0.0/include
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include
/Library/Developer/CommandLineTools/usr/include
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks (framework directory)
End of search list.
testmodule.cpp:2:8: error: expected a module name after 'import'
import <iostream>;
^
[update Tue Oct 18 2:38PM]
Thanks for sigma's comments. I moved [export] section to the beginning of the code. I added cout statement in testmodule.cpp to make iostream required in testmodule.cpp. After the modification I still see compile errors when compile main.cpp
1 // testmodule.cpp
2 export module testmodule;
3 #include <iostream>
4 export int add(int a, int b)
5 {
6 std::cout << "in add()\n";
7 return a + b;
8 }
1 // main.cpp
2 #include <iostream>
3
4 import testmodule;
5
6 using namespace std;
7
8 int main() {
9 cout << "Test Modules" << endl;
10 cout << "add 1 and 2 is " << add(1,2) << endl;
11 }
% clang++ -fmodules-ts -Wall -c -ferror-limit=1 -Xclang -emit-module-interface testmodule.cpp -o testmodule.pcm
% clang++ -fmodules-ts -Wall -v -c -ferror-limit=1 -fprebuilt-module-path=. main.cpp -o main.o
Apple clang version 14.0.0 (clang-1400.0.29.102)
Target: x86_64-apple-darwin21.6.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
"/Library/Developer/CommandLineTools/usr/bin/clang" -cc1 -triple x86_64-apple-macosx12.0.0 -Wundef-prefix=TARGET_OS_ -Wdeprecated-objc-isa-usage -Werror=deprecated-objc-isa-usage -Werror=implicit-function-declaration -emit-obj -mrelax-all --mrelax-relocations -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name main.cpp -mrelocation-model pic -pic-level 2 -mframe-pointer=all -fno-strict-return -fno-rounding-math -funwind-tables=2 -target-sdk-version=12.3 -fvisibility-inlines-hidden-static-local-var -target-cpu penryn -tune-cpu generic -debugger-tuning=lldb -target-linker-version 819.6 -v -resource-dir /Library/Developer/CommandLineTools/usr/lib/clang/14.0.0 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/usr/local/include -stdlib=libc++ -internal-isystem /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1 -internal-isystem /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/local/include -internal-isystem /Library/Developer/CommandLineTools/usr/lib/clang/14.0.0/include -internal-externc-isystem /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include -internal-externc-isystem /Library/Developer/CommandLineTools/usr/include -Wall -Wno-reorder-init-list -Wno-implicit-int-float-conversion -Wno-c99-designator -Wno-final-dtor-non-final-class -Wno-extra-semi-stmt -Wno-misleading-indentation -Wno-quoted-include-in-framework-header -Wno-implicit-fallthrough -Wno-enum-enum-conversion -Wno-enum-float-conversion -Wno-elaborated-enum-base -Wno-reserved-identifier -Wno-gnu-folding-constant -Wno-cast-function-type -Wno-bitwise-instead-of-logical -fdeprecated-macro -fdebug-compilation-dir=/Users/bf/Workspaces/C-plus-plus-Playground/validateC++20/try001 -ferror-limit 1 -stack-protector 1 -fstack-check -mdarwin-stkchk-strong-link -fblocks -fencode-extended-block-signature -fregister-global-dtors-with-atexit -fgnuc-version=4.2.1 -fno-cxx-modules -fmodules-ts -fno-implicit-modules -fprebuilt-module-path=. -fcxx-exceptions -fexceptions -fmax-type-align=16 -fcommon -fcolor-diagnostics -clang-vendor-feature=+messageToSelfInClassMethodIdReturnType -clang-vendor-feature=+disableInferNewAvailabilityFromInit -clang-vendor-feature=+disableNonDependentMemberExprInCurrentInstantiation -fno-odr-hash-protocols -clang-vendor-feature=+enableAggressiveVLAFolding -clang-vendor-feature=+revert09abecef7bbf -clang-vendor-feature=+thisNoAlignAttr -clang-vendor-feature=+thisNoNullAttr -mllvm -disable-aligned-alloc-awareness=1 -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o main.o -x c++ main.cpp
clang -cc1 version 14.0.0 (clang-1400.0.29.102) default target x86_64-apple-darwin21.6.0
ignoring nonexistent directory "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/local/include"
ignoring nonexistent directory "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/Library/Frameworks"
#include "..." search starts here:
#include <...> search starts here:
/usr/local/include
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1
/Library/Developer/CommandLineTools/usr/lib/clang/14.0.0/include
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include
/Library/Developer/CommandLineTools/usr/include
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks (framework directory)
End of search list.
In module 'testmodule' imported from main.cpp:3:
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/type_traits:436:43: error: 'std::integral_constant<bool, false>::value' from module 'testmodule' is not present in definition of 'std::integral_constant<bool, false>' provided earlier
static _LIBCPP_CONSTEXPR const _Tp value = __v;
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/type_traits:436:43: note: declaration of 'value' does not match
static _LIBCPP_CONSTEXPR const _Tp value = __v;
^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
2 errors generated.
[update 2022-10-19]
Thanks sigma. I did some further tests on module fragment test. It seems the clang++ on macOS does not fully support c++ module.
Code,
// interface_part.cppm
export module M:interface_part;
export void World();
Compile command and output,
% clang++ -std=c++20 -fmodules-ts interface_part.cppm --precompile -o M-interface_part.pcm
interface_part.cppm:2:16: error: sorry, module partitions are not yet supported
export module M:interface_part;
^~~~~~~~~~~~~~~
1 error generated.

How to include ft2build.h in SDL2 CMake project

I want to compile a CMake project using SDL2 and SDL_ttf library.
I copied "SDL_ttf.c" & "SDL_ttf.h" into my src folder.
(EDIT: removed it, see comments)
I also added this to my CMakeLists.txt:
include_directories(${SDL2_TTF_INCLUDE_DIR})
freetype2 is also installed
but i get the error after calling make
src/SDL_ttf.c:28:10: fatal error: ft2build.h: No such file or directory
28 | #include <ft2build.h>
How do i properly install SDL_ttf to my system?
(https://github.com/libsdl-org/SDL_ttf/blob/main/CMakeLists.txt)
EDIT:
my CMakeLists.txt:
cmake_minimum_required(VERSION 3.7)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
add_definitions(-std=c++17)
set(CXX_FLAGS "-Wall")
set(CMAKE_CXX_FLAGS, "${CXX_FLAGS}")
project(SDL2Test)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/")
find_package(SDL2 REQUIRED)
find_package(SDL2_ttf REQUIRED)
include_directories(${SDL2_INCLUDE_DIRS} src)
include_directories(${SDL2_TTF_INCLUDE_DIR})
add_executable(Zokoban src/main.cpp src/game.cpp src/controller.cpp src/renderer.cpp src/hero.cpp src/level.cpp)
string(STRIP ${SDL2_LIBRARIES} SDL2_LIBRARIES)
target_link_libraries(Zokoban ${SDL2_LIBRARIES} ${SDL2_TTF_INCLUDE_DIR})
EDIT2:
after sudo make install (SDL_ttf source) and removing the SDL-source files from my repo:
[ 57%] Building CXX object CMakeFiles/Zokoban.dir/src/renderer.cpp.o
/07_Capstone/Zokoban/src/renderer.cpp:9:10: fatal error: SDL_ttf.h: No such file or directory
9 | #include <SDL_ttf.h>
EDIT3
On another machine (debian11) i couldn't even compile the SDL_ttf - source
19:46 $
✔ ~/ThirdParty/SDL_ttf/build [main|✚ 3…1]
19:46 $ make
/bin/bash ./libtool --tag=CC --mode=compile gcc -DPACKAGE_NAME=\"SDL2_ttf\" -DPACKAGE_TARNAME=\"SDL2_ttf\" -DPACKAGE_VERSION=\"2.21.0\" -DPACKAGE_STRING=\"SDL2_ttf\ 2.21.0\" -DPACKAGE_BUGREPORT=\"https://github.com/libsdl-org/SDL_ttf/issues\" -DPACKAGE_URL=\"\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_DLFCN_H=1 -DLT_OBJDIR=\".libs/\" -DSDL_BUILD_MAJOR_VERSION=2 -DSDL_BUILD_MINOR_VERSION=21 -DSDL_BUILD_MICRO_VERSION=0 -DPACKAGE=\"SDL2_ttf\" -DVERSION=\"2.21.0\" -DTTF_USE_HARFBUZZ=1 -DHAVE_CXX11=1 -DALIGNOF_STRUCT_CHAR__=1 -I. -I.. -I../external/freetype/include -DFT2_BUILD_LIBRARY -DFT_PUBLIC_FUNCTION_ATTRIBUTE= -I../external/harfbuzz -I../external/harfbuzz/src -DHAVE_CONFIG_H -DFT_CONFIG_OPTION_USE_HARFBUZZ -g -O2 -D_REENTRANT -I/usr/include/SDL2 -Wall -fvisibility=hidden -DHAVE_OPENGL -MT libSDL2_ttf_la-SDL_ttf.lo -MD -MP -MF .deps/libSDL2_ttf_la-SDL_ttf.Tpo -c -o libSDL2_ttf_la-SDL_ttf.lo `test -f 'SDL_ttf.c' || echo '../'`SDL_ttf.c
libtool: compile: gcc -DPACKAGE_NAME=\"SDL2_ttf\" -DPACKAGE_TARNAME=\"SDL2_ttf\" -DPACKAGE_VERSION=\"2.21.0\" "-DPACKAGE_STRING=\"SDL2_ttf 2.21.0\"" -DPACKAGE_BUGREPORT=\"https://github.com/libsdl-org/SDL_ttf/issues\" -DPACKAGE_URL=\"\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_DLFCN_H=1 -DLT_OBJDIR=\".libs/\" -DSDL_BUILD_MAJOR_VERSION=2 -DSDL_BUILD_MINOR_VERSION=21 -DSDL_BUILD_MICRO_VERSION=0 -DPACKAGE=\"SDL2_ttf\" -DVERSION=\"2.21.0\" -DTTF_USE_HARFBUZZ=1 -DHAVE_CXX11=1 -DALIGNOF_STRUCT_CHAR__=1 -I. -I.. -I../external/freetype/include -DFT2_BUILD_LIBRARY -DFT_PUBLIC_FUNCTION_ATTRIBUTE= -I../external/harfbuzz -I../external/harfbuzz/src -DHAVE_CONFIG_H -DFT_CONFIG_OPTION_USE_HARFBUZZ -g -O2 -D_REENTRANT -I/usr/include/SDL2 -Wall -fvisibility=hidden -DHAVE_OPENGL -MT libSDL2_ttf_la-SDL_ttf.lo -MD -MP -MF .deps/libSDL2_ttf_la-SDL_ttf.Tpo -c ../SDL_ttf.c -fPIC -DPIC -o .libs/libSDL2_ttf_la-SDL_ttf.o
../SDL_ttf.c:28:10: fatal error: ft2build.h: No such file or directory
28 | #include <ft2build.h>
| ^~~~~~~~~~~~
compilation terminated.
make: *** [Makefile:1539: libSDL2_ttf_la-SDL_ttf.lo] Error 1
.. although ft2build.h is obviously installed:
ls /usr/include/freetype2/
freetype ft2build.h
EDIT4:
I downloaded from https://github.com/libsdl-org/SDL_ttf/releases "SDL2_ttf-2.20.0.tar.gz". And could configure, make and sudo make install SDL_ttf.
... but make my project is still not possible
18:03 $ make
[ 14%] Building CXX object CMakeFiles/Zokoban.dir/src/main.cpp.o
[ 28%] Building CXX object CMakeFiles/Zokoban.dir/src/game.cpp.o
[ 42%] Building CXX object CMakeFiles/Zokoban.dir/src/controller.cpp.o
[ 57%] Building CXX object CMakeFiles/Zokoban.dir/src/renderer.cpp.o
/home/Zokoban/src/renderer.cpp:9:10: fatal error: SDL_ttf.h: No such file or directory
9 | #include <SDL_ttf.h>
| ^~~~~~~~~~~
When i tried it with the released sourcecode i get still the error.
~/learning/ThirdParty/SDL_ttf-release-2.20.0/build$ make
depbase=`echo showfont.o | sed 's|[^/]*$|.deps/&|;s|\.o$||'`;\
gcc -DPACKAGE_NAME=\"SDL2_ttf\" -DPACKAGE_TARNAME=\"SDL2_ttf\" -DPACKAGE_VERSION=\"2.20.0\" -DPACKAGE_STRING=\"SDL2_ttf\ 2.20.0\" -DPACKAGE_BUGREPORT=\"https://github.com/libsdl-org/SDL_ttf/issues\" -DPACKAGE_URL=\"\" -DHAVE_STDIO_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_STRINGS_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_UNISTD_H=1 -DSTDC_HEADERS=1 -DHAVE_DLFCN_H=1 -DLT_OBJDIR=\".libs/\" -DSDL_BUILD_MAJOR_VERSION=2 -DSDL_BUILD_MINOR_VERSION=20 -DSDL_BUILD_MICRO_VERSION=0 -DPACKAGE=\"SDL2_ttf\" -DVERSION=\"2.20.0\" -DTTF_USE_HARFBUZZ=1 -DHAVE_CXX11=1 -DALIGNOF_STRUCT_CHAR__=1 -I. -I.. -g -O2 -D_REENTRANT -I/usr/include/SDL2 -Wall -fvisibility=hidden -DHAVE_OPENGL -MT showfont.o -MD -MP -MF $depbase.Tpo -c -o showfont.o ../showfont.c &&\
mv -f $depbase.Tpo $depbase.Po
/bin/bash ./libtool --tag=CC --mode=compile gcc -DPACKAGE_NAME=\"SDL2_ttf\" -DPACKAGE_TARNAME=\"SDL2_ttf\" -DPACKAGE_VERSION=\"2.20.0\" -DPACKAGE_STRING=\"SDL2_ttf\ 2.20.0\" -DPACKAGE_BUGREPORT=\"https://github.com/libsdl-org/SDL_ttf/issues\" -DPACKAGE_URL=\"\" -DHAVE_STDIO_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_STRINGS_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_UNISTD_H=1 -DSTDC_HEADERS=1 -DHAVE_DLFCN_H=1 -DLT_OBJDIR=\".libs/\" -DSDL_BUILD_MAJOR_VERSION=2 -DSDL_BUILD_MINOR_VERSION=20 -DSDL_BUILD_MICRO_VERSION=0 -DPACKAGE=\"SDL2_ttf\" -DVERSION=\"2.20.0\" -DTTF_USE_HARFBUZZ=1 -DHAVE_CXX11=1 -DALIGNOF_STRUCT_CHAR__=1 -I. -I.. -I../external/freetype/include -DFT2_BUILD_LIBRARY -DFT_PUBLIC_FUNCTION_ATTRIBUTE= -I../external/harfbuzz -I../external/harfbuzz/src -DHAVE_CONFIG_H -DFT_CONFIG_OPTION_USE_HARFBUZZ -g -O2 -D_REENTRANT -I/usr/include/SDL2 -Wall -fvisibility=hidden -DHAVE_OPENGL -MT libSDL2_ttf_la-SDL_ttf.lo -MD -MP -MF .deps/libSDL2_ttf_la-SDL_ttf.Tpo -c -o libSDL2_ttf_la-SDL_ttf.lo `test -f 'SDL_ttf.c' || echo '../'`SDL_ttf.c
libtool: compile: gcc -DPACKAGE_NAME=\"SDL2_ttf\" -DPACKAGE_TARNAME=\"SDL2_ttf\" -DPACKAGE_VERSION=\"2.20.0\" "-DPACKAGE_STRING=\"SDL2_ttf 2.20.0\"" -DPACKAGE_BUGREPORT=\"https://github.com/libsdl-org/SDL_ttf/issues\" -DPACKAGE_URL=\"\" -DHAVE_STDIO_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_STRINGS_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_UNISTD_H=1 -DSTDC_HEADERS=1 -DHAVE_DLFCN_H=1 -DLT_OBJDIR=\".libs/\" -DSDL_BUILD_MAJOR_VERSION=2 -DSDL_BUILD_MINOR_VERSION=20 -DSDL_BUILD_MICRO_VERSION=0 -DPACKAGE=\"SDL2_ttf\" -DVERSION=\"2.20.0\" -DTTF_USE_HARFBUZZ=1 -DHAVE_CXX11=1 -DALIGNOF_STRUCT_CHAR__=1 -I. -I.. -I../external/freetype/include -DFT2_BUILD_LIBRARY -DFT_PUBLIC_FUNCTION_ATTRIBUTE= -I../external/harfbuzz -I../external/harfbuzz/src -DHAVE_CONFIG_H -DFT_CONFIG_OPTION_USE_HARFBUZZ -g -O2 -D_REENTRANT -I/usr/include/SDL2 -Wall -fvisibility=hidden -DHAVE_OPENGL -MT libSDL2_ttf_la-SDL_ttf.lo -MD -MP -MF .deps/libSDL2_ttf_la-SDL_ttf.Tpo -c ../SDL_ttf.c -fPIC -DPIC -o .libs/libSDL2_ttf_la-SDL_ttf.o
../SDL_ttf.c:28:10: fatal error: ft2build.h: No such file or directory
28 | #include <ft2build.h>
| ^~~~~~~~~~~~
compilation terminated.
make: *** [Makefile:1536: libSDL2_ttf_la-SDL_ttf.lo] Error 1
My ideas run out :(

why bazel not search system include paths

The error is
.../demo.cc:5:10: fatal error: 'city.h' file not found
#include <city.h>
cityhash is installed by brew install cityhash.
city.h can be found in /usr/local/include.
And, it is actually in the search path of clang.
$ clang -E -xc++ - -v
Apple LLVM version 10.0.1 (clang-1001.0.46.3)
Target: x86_64-apple-darwin18.2.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang" -cc1 -triple x86_64-apple-macosx10.14.0 -Wdeprecated-objc-isa-usage -Werror=deprecated-objc-isa-usage -E -disable-free -disable-llvm-verifier -discard-value-names -main-file-name - -mrelocation-model pic -pic-level 2 -mthread-model posix -mdisable-fp-elim -fno-strict-return -masm-verbose -munwind-tables -target-sdk-version=10.14 -target-cpu penryn -dwarf-column-info -debugger-tuning=lldb -target-linker-version 450.3 -v -resource-dir /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/10.0.1 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk -I/usr/local/include -stdlib=libc++ -Wno-atomic-implicit-seq-cst -Wno-framework-include-private-from-public -Wno-atimport-in-framework-header -Wno-quoted-include-in-framework-header -fdeprecated-macro -fdebug-compilation-dir /Users/formath/git/mlp -ferror-limit 19 -fmessage-length 202 -stack-protector 1 -fblocks -fencode-extended-block-signature -fregister-global-dtors-with-atexit -fobjc-runtime=macosx-10.14.0 -fcxx-exceptions -fexceptions -fmax-type-align=16 -fdiagnostics-show-option -fcolor-diagnostics -o - -x c++ -
clang -cc1 version 10.0.1 (clang-1001.0.46.3) default target x86_64-apple-darwin18.2.0
ignoring nonexistent directory "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/c++/v1"
ignoring nonexistent directory "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/local/include"
ignoring nonexistent directory "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/Library/Frameworks"
#include "..." search starts here:
#include <...> search starts here:
/usr/local/include
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/10.0.1/include
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks (framework directory)
My Bazel version is 1.1.0.
I have saw a same question which is not fixed right now.
https://github.com/bazelbuild/bazel/issues/5391
As a workaround you could add a cc_library for a new_local_repository that wraps a view on /usr/local.
In your WORKSPACE file define a new_local_repository with the path attribute set to /usr/local and the build_file pointing to a BUILD file local to the workspace, for example:
# WORKSPACE
new_local_repository(
name = "usr_local",
path = "/usr/local",
build_file = "third_party/usr_local.BUILD",
)
The third_party/usr_local.BUILD file could have different rules for different libraries you want to wrap. For cityhash you could do something like this (I don't know the structure of the cityhash library, so I'm guessing here about the .so):
# third_party/usr_local.BUILD
cc_library(
name = "cityhash",
hdrs = glob(["include/cityhash/**"]),
srcs = [
"lib64/cityhash.so",
],
includes = [
"include/cityhash",
],
visibility = ["//visibility:public"],
)
Notice that the paths will be relative to the new local repository location (so in this case /usr/local).
Finally in your BUILD file you can reference the cityhash targetu using:
# BUILD
cc_binary(
name = "main",
srcs = [
"main.cc",
],
deps = [
"#usr_local//:cityhash",
],
)
Hope this helps.

Where is my symbol

ALL,
I'm trying to manually compile wxWidgets library - trying to add a new file source to it.
I successfully did compilation:
/Users/AlenaKorot/wxWidgets3.0/buildMac/bk-deps g++ -mmacosx-version-min=10.6 -c -o coredll_desktopenvcmn.o -I./.pch/wxprec_coredll -D__WXOSX_COCOA__ -DWXBUILDING -I/Users/AlenaKorot/wxWidgets3.0/buildMac/src/tiff/libtiff -I../src/tiff/libtiff -I../src/jpeg -I../src/png -I../src/regex -DWXUSINGDLL -DWXMAKINGDLL_CORE -DwxUSE_BASE=0 -dynamic -fPIC -DPIC -Wall -Wundef -Wunused-parameter -Wno-ctor-dtor-privacy -Woverloaded-virtual -Wno-deprecated-declarations -D_FILE_OFFSET_BITS=64 -I/Users/AlenaKorot/wxWidgets3.0/buildMac/lib/wx/include/osx_cocoa-unicode-3.0 -I../include -arch i386 -DWX_PRECOMP -ggdb -O0 -arch i386 -fno-common -fvisibility=hidden -fvisibility-inlines-hidden ../src/common/desktopenvcmn.cpp
/Users/AlenaKorot/wxWidgets3.0/buildMac/bk-deps g++ -mmacosx-version-min=10.6 -c -o coredll_osx_cocoa_desktopenv.o -I./.pch/wxprec_coredll -D__WXOSX_COCOA__ -DWXBUILDING -I/Users/AlenaKorot/wxWidgets3.0/buildMac/src/tiff/libtiff -I../src/tiff/libtiff -I../src/jpeg -I../src/png -I../src/regex -DWXUSINGDLL -DWXMAKINGDLL_CORE -DwxUSE_BASE=0 -dynamic -fPIC -DPIC -D_FILE_OFFSET_BITS=64 -I/Users/AlenaKorot/wxWidgets3.0/buildMac/lib/wx/include/osx_cocoa-unicode-3.0 -I../include -arch i386 -ggdb -O0 -arch i386 -fvisibility=hidden -fvisibility-inlines-hidden ../src/osx/cocoa/desktopenv.mm
And linking:
g++ -mmacosx-version-min=10.6 -dynamiclib -single_module -headerpad_max_install_names -o /Users/AlenaKorot/wxWidgets3.0/buildMac/lib/libwx_osx_cocoau_core-3.0.0.3.0.dylib coredll_desktopenvcmn.o coredll_osx_cocoa_desktopenv.o coredll_event.o coredll_fs_mem.o coredll_msgout.o coredll_utilscmn.o coredll_osx_cocoa_utils.o coredll_artmac.o coredll_osx_brush.o coredll_dialog_osx.o coredll_osx_fontutil.o coredll_osx_imaglist.o coredll_osx_minifram.o coredll_nonownedwnd_osx.o coredll_osx_palette.o coredll_osx_pen.o coredll_toplevel_osx.o coredll_uiaction_osx.o coredll_utils_osx.o coredll_window_osx.o coredll_core_bitmap.o coredll_core_colour.o coredll_core_dcmemory.o coredll_core_display.o coredll_core_fontenum.o coredll_hid.o coredll_printmac.o coredll_core_timer.o coredll_utilsexc_cf.o coredll_apptraits.o coredll_anybutton_osx.o coredll_bmpbuttn_osx.o coredll_button_osx.o coredll_checkbox_osx.o coredll_checklst_osx.o coredll_choice_osx.o coredll_combobox_osx.o coredll_dnd_osx.o coredll_gauge_osx.o coredll_listbox_osx.o coredll_menu_osx.o coredll_menuitem_osx.o coredll_notebook_osx.o coredll_printdlg_osx.o coredll_radiobox_osx.o coredll_radiobut_osx.o coredll_scrolbar_osx.o coredll_slider_osx.o coredll_spinbutt_osx.o coredll_srchctrl_osx.o coredll_statbox_osx.o coredll_statline_osx.o coredll_stattext_osx.o coredll_textentry_osx.o coredll_textctrl_osx.o coredll_tglbtn_osx.o coredll_toolbar_osx.o coredll_webkit.o coredll_colordlgosx.o coredll_fontdlgosx.o coredll_osx_accel.o coredll_carbon_clipbrd.o coredll_carbon_cursor.o coredll_carbon_fontdlg.o coredll_carbon_gdiobj.o coredll_carbon_icon.o coredll_carbon_app.o coredll_carbon_combobox.o coredll_carbon_control.o coredll_carbon_dataobj.o coredll_carbon_dcclient.o coredll_carbon_dcprint.o coredll_carbon_dcscreen.o coredll_glgrab.o coredll_carbon_graphics.o coredll_carbon_font.o coredll_carbon_frame.o coredll_carbon_mdi.o coredll_carbon_metafile.o coredll_carbon_overlay.o coredll_carbon_popupwin.o coredll_carbon_renderer.o coredll_carbon_settings.o coredll_statbrma.o coredll_carbon_region.o coredll_utilscocoa.o coredll_generic_caret.o coredll_clrpickerg.o coredll_collpaneg.o coredll_colrdlgg.o coredll_dirdlgg.o coredll_generic_fdrepdlg.o coredll_filedlgg.o coredll_filepickerg.o coredll_fontdlgg.o coredll_fontpickerg.o coredll_generic_listctrl.o coredll_prntdlgg.o coredll_generic_statusbr.o coredll_generic_textmeasure.o coredll_cocoa_anybutton.o coredll_osx_cocoa_button.o coredll_osx_cocoa_checkbox.o coredll_osx_cocoa_choice.o coredll_osx_cocoa_colour.o coredll_osx_cocoa_combobox.o coredll_osx_cocoa_dialog.o coredll_osx_cocoa_dirdlg.o coredll_cocoa_dnd.o coredll_osx_cocoa_evtloop.o coredll_osx_cocoa_filedlg.o coredll_osx_cocoa_gauge.o coredll_osx_cocoa_listbox.o coredll_osx_cocoa_menu.o coredll_osx_cocoa_menuitem.o coredll_osx_cocoa_msgdlg.o coredll_cocoa_nonownedwnd.o coredll_osx_cocoa_notebook.o coredll_osx_cocoa_radiobut.o coredll_preferences.o coredll_cocoa_printdlg.o coredll_osx_cocoa_scrolbar.o coredll_osx_cocoa_slider.o coredll_osx_cocoa_spinbutt.o coredll_cocoa_srchctrl.o coredll_osx_cocoa_statbox.o coredll_cocoa_statline.o coredll_osx_cocoa_stattext.o coredll_osx_cocoa_textctrl.o coredll_cocoa_tglbtn.o coredll_osx_cocoa_toolbar.o coredll_osx_cocoa_tooltip.o coredll_osx_cocoa_window.o coredll_accelcmn.o coredll_accesscmn.o coredll_anidecod.o coredll_affinematrix2d.o coredll_appcmn.o coredll_artprov.o coredll_artstd.o coredll_arttango.o coredll_bmpbase.o coredll_bmpbtncmn.o coredll_bookctrl.o coredll_btncmn.o coredll_cairo.o coredll_checkboxcmn.o coredll_checklstcmn.o coredll_choiccmn.o coredll_clipcmn.o coredll_clrpickercmn.o coredll_colourcmn.o coredll_colourdata.o coredll_combocmn.o coredll_cmdproc.o coredll_cmndata.o coredll_containr.o coredll_cshelp.o coredll_ctrlcmn.o coredll_ctrlsub.o coredll_dcbase.o coredll_dcbufcmn.o coredll_dcgraph.o coredll_dcsvg.o coredll_dirctrlcmn.o coredll_dlgcmn.o coredll_dndcmn.o coredll_dobjcmn.o coredll_docmdi.o coredll_docview.o coredll_dpycmn.o coredll_dseldlg.o coredll_effects.o coredll_fddlgcmn.o coredll_filectrlcmn.o coredll_filehistorycmn.o coredll_filepickercmn.o coredll_fontpickercmn.o coredll_fldlgcmn.o coredll_fontcmn.o coredll_fontdata.o coredll_graphicc.o coredll_fontenumcmn.o coredll_fontmap.o coredll_fontutilcmn.o coredll_framecmn.o coredll_gaugecmn.o coredll_gbsizer.o coredll_gdicmn.o coredll_geometry.o coredll_gifdecod.o coredll_graphcmn.o coredll_headercolcmn.o coredll_headerctrlcmn.o coredll_helpbase.o coredll_iconbndl.o coredll_imagall.o coredll_imagbmp.o coredll_image.o coredll_imagfill.o coredll_imaggif.o coredll_imagiff.o coredll_imagjpeg.o coredll_imagpcx.o coredll_imagpng.o coredll_imagpnm.o coredll_imagtga.o coredll_imagtiff.o coredll_imagxpm.o coredll_layout.o coredll_lboxcmn.o coredll_listctrlcmn.o coredll_markupparser.o coredll_matrix.o coredll_menucmn.o coredll_modalhook.o coredll_mousemanager.o coredll_nbkbase.o coredll_overlaycmn.o coredll_ownerdrwcmn.o coredll_paper.o coredll_panelcmn.o coredll_persist.o coredll_pickerbase.o coredll_popupcmn.o coredll_preferencescmn.o coredll_prntbase.o coredll_quantize.o coredll_radiobtncmn.o coredll_radiocmn.o coredll_rearrangectrl.o coredll_rendcmn.o coredll_rgncmn.o coredll_scrolbarcmn.o coredll_settcmn.o coredll_sizer.o coredll_slidercmn.o coredll_spinbtncmn.o coredll_spinctrlcmn.o coredll_srchcmn.o coredll_statbar.o coredll_statbmpcmn.o coredll_statboxcmn.o coredll_statlinecmn.o coredll_stattextcmn.o coredll_stockitem.o coredll_tbarbase.o coredll_textcmn.o coredll_textentrycmn.o coredll_textmeasurecmn.o coredll_toplvcmn.o coredll_treebase.o coredll_uiactioncmn.o coredll_valgen.o coredll_validate.o coredll_valtext.o coredll_valnum.o coredll_wincmn.o coredll_windowid.o coredll_wrapsizer.o coredll_xpmdecod.o coredll_busyinfo.o coredll_buttonbar.o coredll_choicdgg.o coredll_choicbkg.o coredll_combog.o coredll_dcpsg.o coredll_dirctrlg.o coredll_dragimgg.o coredll_filectrlg.o coredll_headerctrlg.o coredll_generic_infobar.o coredll_listbkg.o coredll_logg.o coredll_markuptext.o coredll_msgdlgg.o coredll_numdlgg.o coredll_progdlgg.o coredll_preferencesg.o coredll_printps.o coredll_renderg.o coredll_richmsgdlgg.o coredll_scrlwing.o coredll_selstore.o coredll_spinctlg.o coredll_splitter.o coredll_srchctlg.o coredll_statbmpg.o coredll_stattextg.o coredll_textdlgg.o coredll_tipwin.o coredll_toolbkg.o coredll_treectlg.o coredll_treebkg.o coredll_vlbox.o coredll_vscroll.o coredll_xmlreshandler.o -L/Users/AlenaKorot/wxWidgets3.0/buildMac/lib -L/Users/AlenaKorot/wxWidgets3.0/buildMac/lib -install_name /usr/local/lib/libwx_osx_cocoau_core-3.0.0.dylib -compatibility_version 4.0 -current_version 4.0 -arch i386 -framework IOKit -framework Carbon -framework Cocoa -framework AudioToolbox -framework System -framework OpenGL -lwxtiff-3.0 -lwxjpeg-3.0 -lwxpng-3.0 -framework WebKit -lwxregexu-3.0 -arch i386 -framework IOKit -framework Carbon -framework Cocoa -framework AudioToolbox -framework System -framework OpenGL -lz -lpthread -liconv -lwx_baseu-3.0 -lz -lpthread -liconv
Now, here is the strange thing:
Alena-Korots-MacBook:buildMac AlenaKorot$ nm -g coredll_osx_cocoa_desktopenv.o | grep -i desktopenv000001ca T __ZN12wxDesktopEnv15MoveFileToTrashERK8wxString
00019dc8 S __ZN12wxDesktopEnv15MoveFileToTrashERK8wxString.eh
00000444 T __ZN12wxDesktopEnv20MoveDirectoryToTrashERK8wxString
00019df8 S __ZN12wxDesktopEnv20MoveDirectoryToTrashERK8wxString.eh
000000aa T __ZN12wxDesktopEnv20MoveFileToRecycleBinERK8wxString
00019c10 S __ZN12wxDesktopEnv20MoveFileToRecycleBinERK8wxString.eh
0000015a T __ZN12wxDesktopEnvC1Ev
00000000 T __ZN12wxDesktopEnvC2Ev
00000070 T __ZN12wxDesktopEnvD0Ev
00000036 T __ZN12wxDesktopEnvD1Ev
00000190 T __ZN12wxDesktopEnvD2Ev
U __ZN16wxDesktopEnvBase20MoveFileToRecycleBinERK8wxString
0001976c S __ZN16wxDesktopEnvBaseC2Ev
00019ba0 S __ZTI12wxDesktopEnv
U __ZTI16wxDesktopEnvBase
00019b5a S __ZTS12wxDesktopEnv
00019b88 S __ZTV12wxDesktopEnv
U __ZTV16wxDesktopEnvBase
In the object file there are wxDesktopEnv constructor and wxDesktopEnvBase constructor. However:
Alena-Korots-MacBook:lib AlenaKorot$ nm -g libwx_osx_cocoau_core-3.0.dylib | grep -i desktop
Alena-Korots-MacBook:lib AlenaKorot$
those symbols are missing from the dylib.
As you can see I'm linking against the appropriate *.o files.
What do I do to fix it? And where my symbols are?
Thank you.
P.S.: Sorry for such a long post with a bit code quote.
Problem solved.
I tried to do the build with mixed directories.
Sorry for the noise.

Engine Matlab issues

I am triyng to implement Matlab in a c++ program. http://www.cl.cam.ac.uk/~sjeh3/wii/
The application is using gtk a wii mote lib and the Matlab Camera Calibration Toolbox (http://www.vision.caltech.edu/bouguetj/calib_doc/ ). it works perfectly.
I want to use matlab ploting tools to build a graphic provided by the application. But i am having issues building the app with matlab engine .
In the main.cpp i just added the code from the matlab example engdemo.cpp in the main function and included engine.h and mex.h.
Even with the examples like engdemo.cpp i always have this error :
mex: link of ' "...mexa64"' failed.
here are the console views:
root#ubuntu:/home/hugo/Bureau/sjeh3-wii/wmgui# ./build2
----------------------------------------------------------------
-> mbuildopts.sh sourced from directory (DIR = $HOME/.matlab/$REL_VERSION)
FILE = /root/.matlab/R2009b/mbuildopts.sh
----------------------------------------------------------------
-> TMW_ROOT = /home/hugo/Matlab
-> CC = g++-4.1
-> CC flags:
CFLAGS = -ansi -D_GNU_SOURCE -I/home/hugo/Matlab/extern/include/cpp -I/home/hugo/Matlab/extern/include -DUNIX -DX11 -DGLNXA64 -DGCC -pthread
CDEBUGFLAGS = -g
COPTIMFLAGS = -O -DNDEBUG
CLIBS = -Wl,-rpath-link,/home/hugo/Matlab/bin/glnxa64 -L/home/hugo/Matlab/runtime/glnxa64 -lmwmclmcrrt -lm
arguments =
-> LD = g++-4.1
-> Link flags:
LDFLAGS = -pthread
LDDEBUGFLAGS = -g
LDOPTIMFLAGS = -O
arguments = -L/usr/lib/ -L../toolbox -L../libcwiid -L../libcwiid -L/opt/gnome/lib64 -L/home/hugo/Matlab/bin/glnxa64 -L/home/hugo/Matlab/extern/include -L../../matlablibtest/toolbox
----------------------------------------------------------------
-> g++-4.1 -c -I/usr/include/cairo -I/usr/include/freetype2 -I/usr/include/libpng12 -I/opt/gnome/include/gtk-2.0 -I/usr/include/gtk-2.0 -I/usr/include/atk-1.0 -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/lib/gtk-2.0/include -I../libcwiid -I../toolbox -I/opt/matlab/extern/include -I/usr/lib -I/home/hugo/Matlab/extern/include -I/home/hugo/Matlab/bin/glnxa64 -ansi -D_GNU_SOURCE -I/home/hugo/Matlab/extern/include/cpp -I/home/hugo/Matlab/extern/include -DUNIX -DX11 -DGLNXA64 -DGCC -pthread -g "main.cpp"
-> g++-4.1 -c -I/usr/include/cairo -I/usr/include/freetype2 -I/usr/include/libpng12 -I/opt/gnome/include/gtk-2.0 -I/usr/include/gtk-2.0 -I/usr/include/atk-1.0 -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/lib/gtk-2.0/include -I../libcwiid -I../toolbox -I/opt/matlab/extern/include -I/usr/lib -I/home/hugo/Matlab/extern/include -I/home/hugo/Matlab/bin/glnxa64 -ansi -D_GNU_SOURCE -I/home/hugo/Matlab/extern/include/cpp -I/home/hugo/Matlab/extern/include -DUNIX -DX11 -DGLNXA64 -DGCC -pthread -g "interface.cpp"
-> g++-4.1 -c -I/usr/include/cairo -I/usr/include/freetype2 -I/usr/include/libpng12 -I/opt/gnome/include/gtk-2.0 -I/usr/include/gtk-2.0 -I/usr/include/atk-1.0 -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/lib/gtk-2.0/include -I../libcwiid -I../toolbox -I/opt/matlab/extern/include -I/usr/lib -I/home/hugo/Matlab/extern/include -I/home/hugo/Matlab/bin/glnxa64 -ansi -D_GNU_SOURCE -I/home/hugo/Matlab/extern/include/cpp -I/home/hugo/Matlab/extern/include -DUNIX -DX11 -DGLNXA64 -DGCC -pthread -g "support.cpp"
-> g++-4.1 -g -pthread -L/usr/lib/ -L../toolbox -L../libcwiid -L../libcwiid -L/opt/gnome/lib64 -L/home/hugo/Matlab/bin/glnxa64 -L/home/hugo/Matlab/extern/include -L../../matlablibtest/toolbox -o wmgui main.o interface.o support.o -Wl,-rpath-link,/home/hugo/Matlab/bin/glnxa64 -L/home/hugo/Matlab/runtime/glnxa64 -lmwmclmcrrt -lm -lcalib -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgdk_pixbuf-2.0 -lpangocairo-1.0 -lpango-1.0 -lcairo -lgobject-2.0 -lgmodule-2.0 -ldl -lfreetype -lz -lfontconfig -lexpat -lglitz -lm -lpng12 -lXrender -lX11 -lpthread -lXau -lXdmcp -lgthread-2.0 -lglib-2.0 -lm -lcwiid
main.o: In function `main':
/home/hugo/Bureau/sjeh3-wii/wmgui/main.cpp:363: undefined reference to `engOpen'
/home/hugo/Bureau/sjeh3-wii/wmgui/main.cpp:367: undefined reference to `engEvalString'
collect2: ld returned 1 exit status
mbuild: link of 'wmgui' failed.
root#ubuntu:/home/hugo/Bureau/sjeh3-wii/wmgui# ./build2
-> mexopts.sh sourced from directory (DIR = $HOME/.matlab/$REL_VERSION)
FILE = /root/.matlab/R2009b/mexopts.sh
----------------------------------------------------------------
-> MATLAB = /home/hugo/Matlab
-> CC = gcc-4.1
-> CC flags:
CFLAGS = -ansi -D_GNU_SOURCE -fexceptions -fPIC -fno-omit-frame-pointer -pthread
CDEBUGFLAGS = -g
COPTIMFLAGS = -O -DNDEBUG
CLIBS = -Wl,-rpath-link,/home/hugo/Matlab/bin/glnxa64 -L/home/hugo/Matlab/bin/glnxa64 -lmx -lmex -lmat -lm -lstdc++
arguments = -DMX_COMPAT_32
-> CXX = g++-4.1
-> CXX flags:
CXXFLAGS = -ansi -D_GNU_SOURCE -fPIC -fno-omit-frame-pointer -pthread
CXXDEBUGFLAGS = -g
CXXOPTIMFLAGS = -O -DNDEBUG
CXXLIBS = -Wl,-rpath-link,/home/hugo/Matlab/bin/glnxa64 -L/home/hugo/Matlab/bin/glnxa64 -lmx -lmex -lmat -lm
arguments = -DMX_COMPAT_32
-> FC = g95
-> FC flags:
FFLAGS = -fexceptions -fPIC -fno-omit-frame-pointer
FDEBUGFLAGS = -g
FOPTIMFLAGS = -O
FLIBS = -Wl,-rpath-link,/home/hugo/Matlab/bin/glnxa64 -L/home/hugo/Matlab/bin/glnxa64 -lmx -lmex -lmat -lm
arguments = -DMX_COMPAT_32
-> LD = g++-4.1
-> Link flags:
LDFLAGS = -pthread -shared -Wl,--version-script,/home/hugo/Matlab/extern/lib/glnxa64/mexFunction.map -Wl,--no-undefined
LDDEBUGFLAGS = -g
LDOPTIMFLAGS = -O
LDEXTENSION = .mexa64
arguments = -lang cpp -L/usr/lib/ -L../toolbox -L../libcwiid -lcalib -L../libcwiid -L/opt/gnome/lib64 -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgdk_pixbuf-2.0 -lpangocairo-1.0 -lpango-1.0 -lcairo -lgobject-2.0 -lgmodule-2.0 -ldl -lfreetype -lz -lfontconfig -lexpat -lglitz -lm -lpng12 -lXrender -lX11 -lpthread -lXau -lXdmcp -lgthread-2.0 -lglib-2.0 -lm -lcwiid -L/home/hugo/Matlab/bin/glnxa64 -L/home/hugo/Matlab/extern/include -L../../matlablibtest/toolbox
-> LDCXX =
-> Link flags:
LDCXXFLAGS =
LDCXXDEBUGFLAGS =
LDCXXOPTIMFLAGS =
LDCXXEXTENSION =
arguments = -lang cpp -L/usr/lib/ -L../toolbox -L../libcwiid -lcalib -L../libcwiid -L/opt/gnome/lib64 -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgdk_pixbuf-2.0 -lpangocairo-1.0 -lpango-1.0 -lcairo -lgobject-2.0 -lgmodule-2.0 -ldl -lfreetype -lz -lfontconfig -lexpat -lglitz -lm -lpng12 -lXrender -lX11 -lpthread -lXau -lXdmcp -lgthread-2.0 -lglib-2.0 -lm -lcwiid -L/home/hugo/Matlab/bin/glnxa64 -L/home/hugo/Matlab/extern/include -L../../matlablibtest/toolbox
----------------------------------------------------------------
-> g++-4.1 -c -I/usr/include/cairo -I/usr/include/freetype2 -I/usr/include/libpng12 -I/opt/gnome/include/gtk-2.0 -I/usr/include/gtk-2.0 -I/usr/include/atk-1.0 -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/lib/gtk-2.0/include -I../libcwiid -I../toolbox -I/opt/matlab/extern/include -I/usr/lib -I/home/hugo/Matlab/extern/include -I/home/hugo/Matlab/bin/glnxa64 -I/home/hugo/Matlab/extern/include -I/home/hugo/Matlab/simulink/include -DMATLAB_MEX_FILE -ansi -D_GNU_SOURCE -fPIC -fno-omit-frame-pointer -pthread -DMX_COMPAT_32 -g "main.cpp"
-> g++-4.1 -c -I/usr/include/cairo -I/usr/include/freetype2 -I/usr/include/libpng12 -I/opt/gnome/include/gtk-2.0 -I/usr/include/gtk-2.0 -I/usr/include/atk-1.0 -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/lib/gtk-2.0/include -I../libcwiid -I../toolbox -I/opt/matlab/extern/include -I/usr/lib -I/home/hugo/Matlab/extern/include -I/home/hugo/Matlab/bin/glnxa64 -I/home/hugo/Matlab/extern/include -I/home/hugo/Matlab/simulink/include -DMATLAB_MEX_FILE -ansi -D_GNU_SOURCE -fPIC -fno-omit-frame-pointer -pthread -DMX_COMPAT_32 -g "interface.cpp"
-> g++-4.1 -c -I/usr/include/cairo -I/usr/include/freetype2 -I/usr/include/libpng12 -I/opt/gnome/include/gtk-2.0 -I/usr/include/gtk-2.0 -I/usr/include/atk-1.0 -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/lib/gtk-2.0/include -I../libcwiid -I../toolbox -I/opt/matlab/extern/include -I/usr/lib -I/home/hugo/Matlab/extern/include -I/home/hugo/Matlab/bin/glnxa64 -I/home/hugo/Matlab/extern/include -I/home/hugo/Matlab/simulink/include -DMATLAB_MEX_FILE -ansi -D_GNU_SOURCE -fPIC -fno-omit-frame-pointer -pthread -DMX_COMPAT_32 -g "support.cpp"
-> g++-4.1 -g -pthread -shared -Wl,--version-script,/home/hugo/Matlab/extern/lib/glnxa64/mexFunction.map -Wl,--no-undefined -o "wmgui.mexa64" main.o interface.o support.o -lang cpp -L/usr/lib/ -L../toolbox -L../libcwiid -lcalib -L../libcwiid -L/opt/gnome/lib64 -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgdk_pixbuf-2.0 -lpangocairo-1.0 -lpango-1.0 -lcairo -lgobject-2.0 -lgmodule-2.0 -ldl -lfreetype -lz -lfontconfig -lexpat -lglitz -lm -lpng12 -lXrender -lX11 -lpthread -lXau -lXdmcp -lgthread-2.0 -lglib-2.0 -lm -lcwiid -L/home/hugo/Matlab/bin/glnxa64 -L/home/hugo/Matlab/extern/include -L../../matlablibtest/toolbox -Wl,-rpath-link,/home/hugo/Matlab/bin/glnxa64 -L/home/hugo/Matlab/bin/glnxa64 -lmx -lmex -lmat -lm
g++-4.1: cpp: Aucun fichier ou dossier de ce type
mex: link of ' "wmgui.mexa64"' failed.
#!/bin/sh
(mex or mbuild) -v -g -output wmgui main.cpp interface.cpp support.cpp -lang cpp \
-L/usr/lib/ -L../toolbox -L../libcwiid -lcalib -L../libcwiid -L/opt/gnome/lib64 -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgdk_pixbuf-2.0 -lpangocairo-1.0 -lpango-1.0 -lcairo -lgobject-2.0 -lgmodule-2.0 -ldl -lfreetype -lz -lfontconfig -lexpat -lglitz -lm -lpng12 -lXrender -lX11 -lpthread -lXau -lXdmcp -lgthread-2.0 -lglib-2.0 -lm -lcwiid -L/home/hugo/Matlab/bin/glnxa64 -L/home/hugo/Matlab/extern/include -L../../matlablibtest/toolbox \
-I/usr/include/cairo -I/usr/include/freetype2 -I/usr/include/libpng12 -I/opt/gnome/include/gtk-2.0 -I/usr/include/gtk-2.0 -I/usr/include/atk-1.0 -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/lib/gtk-2.0/include -I../libcwiid -I../toolbox -I/opt/matlab/extern/include -I/usr/lib -I/home/hugo/Matlab/extern/include -I/home/hugo/Matlab/bin/glnxa64
I forgot to say that i wanted to use Matlab engine and not my c++ application in matlab. maybe it wasn't so clear. I don't think the program will work as a mex-file.
Sincerely,
Hugo
If found my issue. i was compiling my application using mexopts.sh conf and not engopts.sh
After the succeful compilation i had the Error Can't start Matlab engine. i just apt-get install csh. and it work.
Your linux build command is broken. the compiler is missing some paths to some library.
#!/bin/sh
(mex or mbuild) -v -g -output wmgui main.cpp interface.cpp support.cpp -lang cpp \
-L/usr/lib/ -L../toolbox -L../libcwiid -lcalib -L../libcwiid -L/opt/gnome/lib64 -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgdk_pixbuf-2.0 -lpangocairo-1.0 -lpango-1.0 -lcairo -lgobject-2.0 -lgmodule-2.0 -ldl -lfreetype -lz -lfontconfig -lexpat -lglitz -lm -lpng12 -lXrender -lX11 -lpthread -lXau -lXdmcp -lgthread-2.0 -lglib-2.0 -lm -lcwiid -L/home/hugo/Matlab/bin/glnxa64 -L/home/hugo/Matlab/extern/include -L../../matlablibtest/toolbox \
-I/usr/include/cairo -I/usr/include/freetype2 -I/usr/include/libpng12 -I/opt/gnome/include/gtk-2.0 -I/usr/include/gtk-2.0 -I/usr/include/atk-1.0 -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/lib/gtk-2.0/include -I../libcwiid -I../toolbox -I/opt/matlab/extern/include -I/usr/lib -I/home/hugo/Matlab/extern/include -I/home/hugo/Matlab/bin/glnxa64
Normaly you should find your anwser in this line code !
Sincerely
Hugo