Category : shared-libraries

I have a std::vector which need to filled with some random values when library is loaded. but I see it is been reset after library is loaded. Is it because of global and static Library code: static std::vector<uint8_t> g_randomNr{}; __attribute__((constructor)) void generateRandomNrAtStart(void) { static bool firstLoad = false; g_randomNr.clear(); if (!firstLoad) { firstLoad = true; ..

Read more

I’m building a game with raylib and made my own custom button in different files to reuse it when I need it. I watched tons of videos and read docs but I don’t know why it throws undefined reference to CustomButton::CustomButton(). Here’s the error: /usr/bin/ld: CMakeFiles/AstroX.dir/src/main.cpp.o: in function `_GLOBAL__sub_I_main’: main.cpp:(.text.startup+0xaca): undefined reference to `CustomButton::CustomButton(Vector2, float, ..

Read more

I have created a project that is split into several directories, each of the directories creating a shared library with add_library(${PROJECT_NAME} SHARED ${ALL_FILES}) in CMake. I have a test subdirectory where I use add_executable(${PROJECT_NAME} ${ALL_FILES}) # Dependencies target_link_libraries(${PROJECT_NAME} PUBLIC GTest::GTest Boost::log Boost::json magic_enum::magic_enum <other subfolder project name> ) find_package(GTest REQUIRED) enable_testing() include(GoogleTest) gtest_discover_tests(${PROJECT_NAME}) It all ..

Read more