Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Facing linker issue (undefined reference to `oatpp::base::Environment::getComponent) in windows using mingw gcc compiler #934

Open
Jithu-08 opened this issue Apr 25, 2024 · 0 comments

Comments

@Jithu-08
Copy link

I used oatpp starter project to check compatibility in windows for two different compilers.

  1. using MSVC compiler, starter project compiled and linking is success and application ran successfully.
  2. using msys64/mingw64 gcc compiler, facing below linker issues.

Can somebody help me what I need to do to fix this linker issue. Since it is clearly working with MSVC compiler i am not able to find out what is going wrong while using gcc compiler.

`PS C:\Users\Downloads\oatpp-starter-master\oatpp-starter-master\build> cmake -DCMAKE_C_COMPILER="C:/msys64/mingw64/bin/gcc.exe" -DCMAKE_CXX_COMPILER="C:/msys64/mingw64/bin/g++.exe" -G "MinGW Makefiles" --fresh ..
-- The C compiler identification is GNU 13.2.0
-- The CXX compiler identification is GNU 13.2.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/msys64/mingw64/bin/gcc.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/msys64/mingw64/bin/g++.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done (5.1s)
-- Generating done (0.1s)
-- Build files have been written to: C:/Users/Downloads/oatpp-starter-master/oatpp-starter-master/build

PS C:\Users\Downloads\oatpp-starter-master\oatpp-starter-master\build> cmake --build .
[ 14%] Building CXX object CMakeFiles/my-project-lib.dir/src/controller/MyController.cpp.obj
[ 28%] Linking CXX static library libmy-project-lib.a
[ 28%] Built target my-project-lib
[ 42%] Building CXX object CMakeFiles/my-project-exe.dir/src/App.cpp.obj
[ 57%] Linking CXX executable my-project-exe.exe
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\my-project-exe.dir/objects.a(App.cpp.obj):App.cpp:(.text+0xc8): **undefined reference to oatpp::base::Environment::getComponent**(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)' C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\my-project-exe.dir/objects.a(App.cpp.obj):App.cpp:(.text+0x141): undefined reference to oatpp::web::server::HttpRouter::addController(std::shared_ptroatpp::web::server::api::ApiController const&)'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\my-project-exe.dir/objects.a(App.cpp.obj):App.cpp:(.text+0x1b8): undefined reference to oatpp::base::Environment::getComponent(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)' C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\my-project-exe.dir/objects.a(App.cpp.obj):App.cpp:(.text+0x228): undefined reference to oatpp::base::Environment::getComponent(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&)'`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant