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

Building with cmake's fetch content using a cross compiler #2507

Closed
pfeatherstone opened this issue Sep 21, 2021 · 2 comments · Fixed by #2728
Closed

Building with cmake's fetch content using a cross compiler #2507

pfeatherstone opened this issue Sep 21, 2021 · 2 comments · Fixed by #2728

Comments

@pfeatherstone
Copy link

So I have the following in my CMakeLists.txt file:

include(FetchContent)

set(FMT_TEST FF CACHE INTERNAL "disabling fmt tests")

FetchContent_Declare(
        fmt
        GIT_REPOSITORY  https://github.com/fmtlib/fmt.git
        GIT_TAG         8.0.1
        GIT_PROGRESS    TRUE
        USES_TERMINAL_DOWNLOAD TRUE
)

FetchContent_MakeAvailable(fmt)

...
target_link_libraries(mybinary
        PRIVATE fmt::fmt
)

When cross-compiling with say an arm compiler, i get undefined reference errors like this:

<artificial>:(.text.startup+0x1588): undefined reference to `fmt::v8::vprint(fmt::v8::basic_string_view<char>, ...

I'm cross-compiling like this:

cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=arm-openwrt-linux-gcc -DCMAKE_CXX_COMPILER=arm-openwrt-linux-g++ ..

So i'm not specifying a toolchain file.

Now, is this a cmake bug in the FetchContent module, or is this a libfmt bug?

Cheers

@pfeatherstone
Copy link
Author

This works fine when not cross compiling. Note that a short term solution is to use fmt::fmt-header-only

@pfeatherstone
Copy link
Author

Turns out the issue is because i'm compiling with -flto. Looking closely at the logs, i can see the following:

arm-openwrt-linux-ar: CMakeFiles/fmt.dir/src/format.cc.o: plugin needed to handle lto object

I thinks that's it.

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

Successfully merging a pull request may close this issue.

1 participant