Undefined reference
- Dominant language
- C++
- Stars
- 17.1k
- Forks
- 4.3k
- Avg merge
- 3d 18h
- Merged PRs (30d)
- 91
Description
Hello
I have been having issues linking arrow when compiled from source or using msys64 for a C++ project:
[2/2] Linking CXX executable test_project.exe
FAILED: test_project.exe
cmd.exe /C "cd . && C:\Users\netce\AppData\Local\JetBrains\Toolbox\apps\CLion\ch-0\222.4167.35\bin\mingw\bin\g++.exe -g CMakeFiles/test_project.dir/main.cpp.obj -o test_project.exe -Wl,--out-implib,libtest_project.dll.a -Wl,--major-image-version,0,--minor-image-version,0 "C:/Program Files/arrow/lib/arrow_static.lib" -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 && cd ."
C:\Users\netce\AppData\Local\JetBrains\Toolbox\apps\CLion\ch-0\222.4167.35\bin\mingw\bin/ld.exe: CMakeFiles/test_project.dir/main.cpp.obj:C:/Users/netce/CLionProjects/untitled/main.cpp:5: undefined reference to `arrow::int16()'
collect2.exe: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.
My CMakeLists.txt file is:
cmake_minimum_required(VERSION 3.23)
project(test_project)
set(CMAKE_CXX_STANDARD 14)
#set(CMAKE_PREFIX_PATH "C:/msys64/mingw64")
include_directories(C:/Program Files/arrow)
#include_directories(C:/msys64/mingw64)
find_package(Arrow REQUIRED)
if (Arrow_FOUND)
message(STATUS "Found Apache Arrow ${ARROW_VERSION}")
else()
message(FATAL_ERROR "Could NOT find Apache Arrow")
endif()
add_executable(test_project main.cpp)
target_link_libraries(test_project PRIVATE arrow_static)
#target_link_libraries(test_project PRIVATE arrow_shared)
and my main.cpp is:
#include
#include
int main() {
arrow::int16();
std::cout << "Hello, World!" << std::endl;
return 0;
}
Can anybody help me out?
Thanks
Contributor guide
Research direction
Start by reproducing the Windows link failure from the supplied main.cpp and CMakeLists.txt, using the shown CMake configuration and arrow_static target. Inspect the generated link command and the Arrow package configuration to determine why arrow::int16() is unresolved. Done means the minimal project links and runs successfully with the intended Arrow build.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cmake, cpp
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 32/100