Open edbird opened 4 years ago
First, the -L
(uppercase) option specifies an additional path for library search, similar to -I
. It is the -l
(lowercase) that specifies the name (without prefixes or suffixes) of a library to link with.
Second, the linker is very particular about link order, you have to specify dependencies after objects using them. In this case, -lBearLibTerminal
should go after main2.cpp
.
In other words (assuming both .h/.so are in the current directory) your command should look like
g++ -I. -L. main2.cpp -lBearLibTerminal -o app2.exe
Also note that by default Linux binaries do not search for dependencies besides themselves. So the compiled binary won't run failing to find the library it has just linked with a moment ago. Dependencies are supposed to go into system directories =/. To make things simpler, you can make it search the current directory by adding a few flags:
g++ -I. -L. -Wl,-rpath,. main2.cpp -lBearLibTerminal -o app2.exe
Simple example: http://foo.wyrd.name/en:bearlibterminal#documentation
I am currently attempting to compile this with
however I obtain some errors such as
I assumed these symbols would be contained in the file
libBearLibTerminal.so
, but apparently not.I created the .so and .h by compiling this repository using
cmake .; make