#include folder needed to link app

9 messages · Page 1 of 1 (latest)

rugged tiger
#

hey!
can someone explain me why removing the -I flags generates a linking error? and with only two functions

g++ -I./ftxui/include -o main.cpp.o -c src/main.cpp

when i run this command to generate the object file, everything works, but without the -I flag, i get this linking error when i try to link my app:

main.cpp:(.text+0x7a3): undefined reference to `ftxui::window(std::shared_ptr<ftxui::Node>, std::shared_ptr<ftxui::Node>, ftxui::BorderStyle)'
/usr/bin/ld: main.cpp.o: in function `main':
main.cpp:(.text+0xec3): undefined reference to `ftxui::size(ftxui::WidthOrHeight, ftxui::Constraint, int)'
/usr/bin/ld: main.cpp:(.text+0xf9a): undefined reference to `ftxui::Screen::ToString[abi:cxx11]() const'
collect2: error: ld returned 1 exit status
make: *** [Makefile:3: build] Error 

include folder doesn't contains implementation of Screen::ToString, only declaration:

class Screen {
 public:
   // ...
   std::string ToString();
   // ...
}
strong parcelBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.

trim latch
rugged tiger
#

but it only happens with these specific functions, i use other functions from ftxui, and i don't need the include folder in order to link the app

#

i even use Screen::Create without any issue, but Screen::ToString no

#

ok no, i commented out the line with Screen::Create, and i have a shit ton of linking errors
this line was "hiding" other errors

trim latch
#

As to the include not being needed, that’s because the object file includes the linker-readable names of the functions, and the missing errors are probably because the linker bailed, or the compiler decided those paths weren’t being used in the optimization phase

rugged tiger
#

okok thanks for the clarifications !

#

!solved