CMake's PCH support and boost.test linker error

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

CMake's PCH support and boost.test linker error

Boost - Users mailing list
Hello Boost users

I have here a strange problem which occurs only if I try to build with
precompiled headers using CMake. I've configured the project for use
with dynamically linking. The error is:

/usr/bin/ld:
/usr/lib/gcc/x86_64-redhat-linux/10/../../../../lib64/crt1.o: in
function `_start':
(.text+0x24): undefined reference to `main'

Something obvious?

Thanks in advance


The project's reduce is:

---8<--- test_driver.cpp --- 8< ----

#defineBOOST_TEST_MODULE "My Test Suite"

#include<boost/test/unit_test.hpp>
--->8------>8------>8---

---8<--- test_x.cpp --- 8< ----

#include<boost/test/unit_test.hpp>
....
--->8------>8------>8---

---8<--- src/CMakeLists.txt --- 8< ----

...

set_source_files_properties(src/test_xxx.cpp

APPEND PROPERTIES
COMPILE_DEFINITIONS "BOOST_TEST_DYN_LINK"
)
....
--->8------>8------>8------>8------>8------>8---

---8<--- pch.pp --- 8< ----

#pragma once
#include<boost/test/unit_test.hpp>
--->8------>8------>8---
_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: CMake's PCH support and boost.test linker error

Boost - Users mailing list
Hello Boost users

>
> I have here a strange problem which occurs only if I try to build with
> precompiled headers using CMake. I've configured the project for use
> with dynamically linking. The error is:
>
> /usr/bin/ld:
> /usr/lib/gcc/x86_64-redhat-linux/10/../../../../lib64/crt1.o: in
> function `_start':
> (.text+0x24): undefined reference to `main'
>
> Something obvious?
>
> Thanks in advance
>
>
> The project's reduce is:
>
[...]

attached a minimal example. So it can be reproduced.


_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users

CMakeLists.txt (858 bytes) Download Attachment
pch.hpp (53 bytes) Download Attachment
test.cpp (190 bytes) Download Attachment
test_driver.cpp (93 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: CMake's PCH support and boost.test linker error

Boost - Users mailing list
In reply to this post by Boost - Users mailing list
of interest is the error message:

[ 25%] Linking CXX executable boost_utf_pch
/usr/bin/cmake -E cmake_link_script
CMakeFiles/boost_utf_pch.dir/link.txt --verbose=1
/usr/bin/c++ CMakeFiles/boost_utf_pch.dir/test_driver.cpp.o
CMakeFiles/boost_utf_pch.dir/test.cpp.o -o boost_utf_pch
/usr/lib64/libboost_unit_test_framework.so
/usr/bin/ld:
/usr/lib/gcc/x86_64-redhat-linux/10/../../../../lib64/crt1.o: in
function `_start':
(.text+0x24): undefined reference to `main'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/boost_utf_pch.dir/build.make:141:
boost_utf_pch] Error 1
make[2]: Leaving directory '/home/olaf/work/CXX/boost_test_pch/build'
make[1]: *** [CMakeFiles/Makefile2:98: CMakeFiles/boost_utf_pch.dir/all]
Error 2
make[1]: Leaving directory '/home/olaf/work/CXX/boost_test_pch/build'
make: *** [Makefile:106: all] Error 2

and my system:

$ lsb_release -a
LSB Version:
:core-4.1-amd64:core-4.1-noarch:cxx-4.1-amd64:cxx-4.1-noarch:desktop-4.1-amd64:desktop-4.1-noarch:languages-4.1-amd64:languages-4.1-noarch:printing-4.1-amd64:printing-4.1-noarch
Distributor ID:    Fedora
Description:    Fedora release 33 (Thirty Three)
Release:    33
Codename:    ThirtyThree

$ c++ --version
c++ (GCC) 10.2.1 20201125 (Red Hat 10.2.1-9)

Same problems with clang version 11.0.0 (Fedora 11.0.0-2.fc33)


_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users