-
Hello, I'm trying to build and run MyFirstVsgApplication on a Raspberry Pi 4. I've compiled and installed VSG apparently successfully. When I try to build MyFirstVsgApplication, or any of the vsgExampls or vsgXChange I get the same error during link: /usr/bin/ld: /usr/local/lib/arm-linux-gnueabihf/libvsg.a(RecordTraversal.cpp.o): in function (etc) GCC/G++ Version: Any idea ? I've tried to add set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} -latomic") on CMakeLists.txt but it doesn't change anything. Thanks ! |
Beta Was this translation helpful? Give feedback.
Replies: 15 comments 10 replies
-
using target_link_libraries worked, in CMakeLists:
|
Beta Was this translation helpful? Give feedback.
-
Others have been using Pi4's and haven't reported this problem, I'm hoping we'll get feedback on what compiler/options being used to see if there is a pattern behind it. I would rather merge a change to VSG rather than have 3rd party applications add platform specific tweaks to keep things compiling. CMake config support should be able to help us here. |
Beta Was this translation helpful? Give feedback.
-
Hi, Fwiw, on Raspbian 11 64 bit, I built everything from master (the VSG and projects) and it builds fine. As a first test I ran 'vsgdraw -d' and that''s running fine. Next, I checked out MyFirstVsgApplication, ran cmake, build and ran it. All fine working out of the box. I would suggest to apt update, upgrade, reboot and build everything again. If you are using a different setup, please let us know and we can try it out too. |
Beta Was this translation helpful? Give feedback.
-
@brunorzn and @reedev, I have been reviewing the VSG's CMake config set up and the following block of CMake script in VulkanSceneGra/src/vsg/CMakeLists.txt looks relevant: # Check for std::atomic
if(NOT MSVC AND NOT ANDROID AND NOT APPLE)
check_cxx_source_compiles("
#include <atomic>
std::atomic<int> a;
int main() { return a; }"
HAVE_CXX_ATOMIC_WITHOUT_LIB
)
if(NOT HAVE_CXX_ATOMIC_WITHOUT_LIB)
find_library(CXX_ATOMIC_LIBRARIES NAMES atomic atomic.so.1 libatomic.so.1 REQUIRED)
list(APPEND LIBRARIES ${CXX_ATOMIC_LIBRARIES})
endif()
endif() My best guess is that this test is passing on 32bit build but the VSG is then using 64bit atomics which aren't supported. If this is correct then just changing to test a wider range of atomics would help. I will create a branch of the VSG and experiment. |
Beta Was this translation helpful? Give feedback.
-
@brunorzn I have added a check for 64bit atomic to the check_cxx_source_compiles(..) test. https://github.com/vsg-dev/VulkanSceneGraph/tree/atomic The cmake script now looks like: # Check for std::atomic
if(NOT MSVC AND NOT ANDROID AND NOT APPLE)
check_cxx_source_compiles("
#include <atomic>
std::atomic_uint32_t a32;
std::atomic_uint64_t a64;
int main() { return a32; }"
HAVE_CXX_ATOMIC_WITHOUT_LIB
)
if(NOT HAVE_CXX_ATOMIC_WITHOUT_LIB)
find_library(CXX_ATOMIC_LIBRARIES NAMES atomic atomic.so.1 libatomic.so.1 REQUIRED)
list(APPEND LIBRARIES ${CXX_ATOMIC_LIBRARIES})
endif()
endif() @brunorzn Could you test this out on your system, you'll need to revert your changes to MyFirstVsgApplication to make sure that things are now working out the box. If this works I'll merged with master and it'll be part of the next VSG release. |
Beta Was this translation helpful? Give feedback.
-
Hi @brunorzn could you test the atomic branch of the VSG, I've made a fix but can't merge with this with VSG master without confirmation that it works on Pi4 with 32bit. |
Beta Was this translation helpful? Give feedback.
-
Hi, Sorry for my late reply, I was away from the PI for some time, back yesterday. Unfortunately, I can't reproduce the problem anymore. I've cloned a fresh vsgExample and I can link it successfully on my PI. I'm looking at what may have changed - I've installed boost in the meantime, but I don't think that's it. I'm investigating |
Beta Was this translation helpful? Give feedback.
-
I've tried with vsgXchange and was able to reproduce the error. Adding your code didn't change anything, same error. I had to add the following line also: +INCLUDE(CheckCXXSourceCompiles) Adding the line target_link_libraries(vsgXchange INTERFACE -latomic) still fixes the error Hope that helps |
Beta Was this translation helpful? Give feedback.
-
Where did you add the INCLUDE? You provide a diff? What error occurred if you didn't include the above change? The adding of atmomic check in cmake is to see if -latomic is required then if it is then add it to link line. It might be that the check is failing or the atomic lib isn't being added to the VSG's cmake config files that are installed in lib/cmake/vsg. Unfortunately I can't test out and answer these questions as I don't have a Raspberry Pi4 so need the community that have them to step up and figure issues out. |
Beta Was this translation helpful? Give feedback.
-
@brunorzn I have just checked and the VulkanSceneGraph/src/CMAkeLists.txt already has a INCLUDE(CheckCXXSourceCompiles) so I'm lost on where you may have needed to add this and why. |
Beta Was this translation helpful? Give feedback.
-
Apologies if I wasn't clear. VSG compiles without problem, it's when I compile vsgXChange that I got the problem. I've tried on a fresh Raspbian 64 bits install, and I can confirm that everything works properly. |
Beta Was this translation helpful? Give feedback.
-
I have decided to go ahead an merged my changes in the atomic branch as I think they generally make sense. #850. |
Beta Was this translation helpful? Give feedback.
-
On Tue, 13 Jun 2023 at 10:36, Bruno RZN ***@***.***> wrote:
I misunderstood that before. Let me check it out.
You should be able to use VSG master now. I'll also be making a VSG-1.0.7
soon to include the change to atomic check.
… Message ID:
***@***.***
com>
|
Beta Was this translation helpful? Give feedback.
-
For the record, if anyone wants to have VSG running on a Raspberry Pi 4 running Raspbian 32 bits (as of june 2023), you just have to:
That's it ! You should be able to run the examples or MyFirstVSGApplication directly afterwards. |
Beta Was this translation helpful? Give feedback.
-
Glad to hear it now works out of the box. These fixes will be part of the VSG-1.0.7 release I'll tag later this week. |
Beta Was this translation helpful? Give feedback.
Putting more sophisticated code into check_cxx_source_compiles(..) might be able trigger an compile issue. While we can't include vsg/threading/atomics.h we can recreate some of the key code that appears to be tripping up the normal compile. I checked in to VSG master some addition atomic code inspired by include/vsg/threading/atomics.h: fce7e60
Could you try out the latest VSG maste…