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

Link errors #672

Closed
GasparVardanyan opened this issue Jan 4, 2024 · 13 comments
Closed

Link errors #672

GasparVardanyan opened this issue Jan 4, 2024 · 13 comments
Labels
bug This issue is a bug. p2 This is a standard priority issue

Comments

@GasparVardanyan
Copy link

Describe the bug

Compiling sdk (as specified in README) on ArchLinux I'm getting these errors:

/usr/bin/ld: ../../crt/aws-crt-cpp/crt/aws-c-io/libaws-c-io.a(epoll_event_loop.c.o): in function `aws_event_loop_thread':
/home/gaspar/sdk-workspace/aws-iot-device-sdk-cpp-v2/crt/aws-crt-cpp/crt/aws-c-io/source/linux/epoll_event_loop.c:620:(.text+0xc50): undefined reference to `__itt_task_begin_ptr__3_0'
/usr/bin/ld: /home/gaspar/sdk-workspace/aws-iot-device-sdk-cpp-v2/crt/aws-crt-cpp/crt/aws-c-io/source/linux/epoll_event_loop.c:651:(.text+0xd77): undefined reference to `__itt_task_begin_ptr__3_0'
/usr/bin/ld: /home/gaspar/sdk-workspace/aws-iot-device-sdk-cpp-v2/crt/aws-crt-cpp/crt/aws-c-io/source/linux/epoll_event_loop.c:653:(.text+0xdef): undefined reference to `__itt_task_end_ptr__3_0'
/usr/bin/ld: /home/gaspar/sdk-workspace/aws-iot-device-sdk-cpp-v2/crt/aws-crt-cpp/crt/aws-c-io/source/linux/epoll_event_loop.c:656:(.text+0xe37): undefined reference to `__itt_task_end_ptr__3_0'
/usr/bin/ld: /home/gaspar/sdk-workspace/aws-iot-device-sdk-cpp-v2/crt/aws-crt-cpp/crt/aws-c-io/source/linux/epoll_event_loop.c:665:(.text+0x10db): undefined reference to `__itt_task_begin_ptr__3_0'
/usr/bin/ld: /home/gaspar/sdk-workspace/aws-iot-device-sdk-cpp-v2/crt/aws-crt-cpp/crt/aws-c-io/source/linux/epoll_event_loop.c:667:(.text+0x1148): undefined reference to `__itt_task_end_ptr__3_0'
/usr/bin/ld: ../../crt/aws-crt-cpp/crt/aws-c-io/libaws-c-io.a(stream.c.o): in function `aws_input_stream_read':
/home/gaspar/sdk-workspace/aws-iot-device-sdk-cpp-v2/crt/aws-crt-cpp/crt/aws-c-io/source/stream.c:36:(.text+0x2da): undefined reference to `__itt_task_begin_ptr__3_0'
/usr/bin/ld: /home/gaspar/sdk-workspace/aws-iot-device-sdk-cpp-v2/crt/aws-crt-cpp/crt/aws-c-io/source/stream.c:38:(.text+0x341): undefined reference to `__itt_task_end_ptr__3_0'
/usr/bin/ld: ../../crt/aws-crt-cpp/crt/aws-c-io/libaws-c-io.a(tracing.c.o): in function `aws_io_tracing_init':
/home/gaspar/sdk-workspace/aws-iot-device-sdk-cpp-v2/crt/aws-crt-cpp/crt/aws-c-io/source/tracing.c:15:(.text+0xc): undefined reference to `__itt_domain_create_ptr__3_0'
/usr/bin/ld: /home/gaspar/sdk-workspace/aws-iot-device-sdk-cpp-v2/crt/aws-crt-cpp/crt/aws-c-io/source/tracing.c:16:(.text+0x2d): undefined reference to `__itt_string_handle_create_ptr__3_0'
/usr/bin/ld: ../../crt/aws-crt-cpp/crt/aws-c-io/libaws-c-io.a(epoll_event_loop.c.o): in function `aws_event_loop_thread':
/home/gaspar/sdk-workspace/aws-iot-device-sdk-cpp-v2/crt/aws-crt-cpp/crt/aws-c-io/source/linux/epoll_event_loop.c:620:(.text+0xc50): undefined reference to `__itt_task_begin_ptr__3_0'
/usr/bin/ld: /home/gaspar/sdk-workspace/aws-iot-device-sdk-cpp-v2/crt/aws-crt-cpp/crt/aws-c-io/source/linux/epoll_event_loop.c:651:(.text+0xd77): undefined reference to `__itt_task_begin_ptr__3_0'
/usr/bin/ld: /home/gaspar/sdk-workspace/aws-iot-device-sdk-cpp-v2/crt/aws-crt-cpp/crt/aws-c-io/source/linux/epoll_event_loop.c:653:(.text+0xdef): undefined reference to `__itt_task_end_ptr__3_0'
/usr/bin/ld: /home/gaspar/sdk-workspace/aws-iot-device-sdk-cpp-v2/crt/aws-crt-cpp/crt/aws-c-io/source/linux/epoll_event_loop.c:656:(.text+0xe37): undefined reference to `__itt_task_end_ptr__3_0'
/usr/bin/ld: /home/gaspar/sdk-workspace/aws-iot-device-sdk-cpp-v2/crt/aws-crt-cpp/crt/aws-c-io/source/linux/epoll_event_loop.c:665:(.text+0x10db): undefined reference to `__itt_task_begin_ptr__3_0'
/usr/bin/ld: /home/gaspar/sdk-workspace/aws-iot-device-sdk-cpp-v2/crt/aws-crt-cpp/crt/aws-c-io/source/linux/epoll_event_loop.c:667:(.text+0x1148): undefined reference to `__itt_task_end_ptr__3_0'
/usr/bin/ld: ../../crt/aws-crt-cpp/crt/aws-c-io/libaws-c-io.a(stream.c.o): in function `aws_input_stream_read':
/home/gaspar/sdk-workspace/aws-iot-device-sdk-cpp-v2/crt/aws-crt-cpp/crt/aws-c-io/source/stream.c:36:(.text+0x2da): undefined reference to `__itt_task_begin_ptr__3_0'
/usr/bin/ld: /home/gaspar/sdk-workspace/aws-iot-device-sdk-cpp-v2/crt/aws-crt-cpp/crt/aws-c-io/source/stream.c:38:(.text+0x341): undefined reference to `__itt_task_end_ptr__3_0'
/usr/bin/ld: ../../crt/aws-crt-cpp/crt/aws-c-io/libaws-c-io.a(tracing.c.o): in function `aws_io_tracing_init':
/home/gaspar/sdk-workspace/aws-iot-device-sdk-cpp-v2/crt/aws-crt-cpp/crt/aws-c-io/source/tracing.c:15:(.text+0xc): undefined reference to `__itt_domain_create_ptr__3_0'
/usr/bin/ld: /home/gaspar/sdk-workspace/aws-iot-device-sdk-cpp-v2/crt/aws-crt-cpp/crt/aws-c-io/source/tracing.c:16:(.text+0x2d): undefined reference to `__itt_string_handle_create_ptr__3_0'
collect2: error: ld returned 1 exit status
make[2]: *** [eventstream_rpc/tests/CMakeFiles/EventstreamRpc-cpp-tests.dir/build.make:176: eventstream_rpc/tests/EventstreamRpc-cpp-tests] Error 1
make[1]: *** [CMakeFiles/Makefile2:2088: eventstream_rpc/tests/CMakeFiles/EventstreamRpc-cpp-tests.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
collect2: error: ld returned 1 exit status
make[2]: *** [devicedefender/tests/CMakeFiles/IotDeviceDefender-cpp-tests.dir/build.make:146: devicedefender/tests/IotDeviceDefender-cpp-tests] Error 1
make[1]: *** [CMakeFiles/Makefile2:2251: devicedefender/tests/CMakeFiles/IotDeviceDefender-cpp-tests.dir/all] Error 2
make: *** [Makefile:146: all] Error 2

Full log: http://sprunge.us/INMUSM

Expected Behavior

To be able to compile the sdk.

Current Behavior

I can't compile sdk because of link errors.

Reproduction Steps

Get a working ArchLinux environment and follow the steps in readme.

Possible Solution

Link ittapi.

Additional Information/Context

No response

SDK version used

current 'main' branch

Environment details (OS name and version, etc.)

Linux odyssey 6.6.8-arch1-1 #1 SMP PREEMPT_DYNAMIC Thu, 21 Dec 2023 19:01:01 +0000 x86_64 GNU/Linux

@GasparVardanyan GasparVardanyan added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Jan 4, 2024
@GasparVardanyan
Copy link
Author

Full process of building: http://sprunge.us/gJ8adS

@GasparVardanyan
Copy link
Author

I've builded and installed ittapi manually and in my case these changes helped to successfully build the sdk:

diff --git a/devicedefender/CMakeLists.txt b/devicedefender/CMakeLists.txt
index 4040ca7..62161ac 100644
--- a/devicedefender/CMakeLists.txt
+++ b/devicedefender/CMakeLists.txt
@@ -101,7 +101,7 @@ if (BUILD_DEPS)
     endif()
 endif()
 
-target_link_libraries(IotDeviceDefender-cpp IotDeviceCommon-cpp)
+target_link_libraries(IotDeviceDefender-cpp IotDeviceCommon-cpp /usr/local/lib/libittnotify.a)
 
 install(FILES ${AWS_IOTDEVICEDEFENDER_HEADERS} DESTINATION "include/aws/iotdevicedefender/" COMPONENT Development)
 
diff --git a/eventstream_rpc/CMakeLists.txt b/eventstream_rpc/CMakeLists.txt
index 5e5aa13..1e41fd5 100644
--- a/eventstream_rpc/CMakeLists.txt
+++ b/eventstream_rpc/CMakeLists.txt
@@ -98,7 +98,7 @@ if (NOT IS_SUBDIRECTORY_INCLUDE)
 endif()
 
 
-target_link_libraries(EventstreamRpc-cpp ${DEP_AWS_LIBS})
+target_link_libraries(EventstreamRpc-cpp ${DEP_AWS_LIBS} /usr/local/lib/libittnotify.a)
 
 install(FILES ${AWS_EVENTSTREAMRPC_HEADERS} DESTINATION "include/aws/eventstreamrpc/" COMPONENT Development)

@jmklix
Copy link
Member

jmklix commented Jan 5, 2024

I'm glad you were able to get this working for your environment. Are you running into any other build issues?

@jmklix jmklix added response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 2 days. p2 This is a standard priority issue and removed needs-triage This issue or PR still needs to be triaged. labels Jan 5, 2024
@GasparVardanyan
Copy link
Author

Thank you for quick response. That was the only issue.

@github-actions github-actions bot removed the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 2 days. label Jan 5, 2024
@bretambrose
Copy link
Contributor

This should be investigated further. A user needing to patch the source tree isn't a situation we want to be in.

@GasparVardanyan
Copy link
Author

Also in mqtt5 pubsub example was that problem.

diff --git a/devicedefender/CMakeLists.txt b/devicedefender/CMakeLists.txt
index 4040ca7..62161ac 100644
--- a/devicedefender/CMakeLists.txt
+++ b/devicedefender/CMakeLists.txt
@@ -101,7 +101,7 @@ if (BUILD_DEPS)
     endif()
 endif()
 
-target_link_libraries(IotDeviceDefender-cpp IotDeviceCommon-cpp)
+target_link_libraries(IotDeviceDefender-cpp IotDeviceCommon-cpp /usr/local/lib/libittnotify.a)
 
 install(FILES ${AWS_IOTDEVICEDEFENDER_HEADERS} DESTINATION "include/aws/iotdevicedefender/" COMPONENT Development)
 
diff --git a/eventstream_rpc/CMakeLists.txt b/eventstream_rpc/CMakeLists.txt
index 5e5aa13..1e41fd5 100644
--- a/eventstream_rpc/CMakeLists.txt
+++ b/eventstream_rpc/CMakeLists.txt
@@ -98,7 +98,7 @@ if (NOT IS_SUBDIRECTORY_INCLUDE)
 endif()
 
 
-target_link_libraries(EventstreamRpc-cpp ${DEP_AWS_LIBS})
+target_link_libraries(EventstreamRpc-cpp ${DEP_AWS_LIBS} /usr/local/lib/libittnotify.a)
 
 install(FILES ${AWS_EVENTSTREAMRPC_HEADERS} DESTINATION "include/aws/eventstreamrpc/" COMPONENT Development)
 
diff --git a/samples/mqtt5/mqtt5_pubsub/CMakeLists.txt b/samples/mqtt5/mqtt5_pubsub/CMakeLists.txt
index b2d6dda..5fd9912 100644
--- a/samples/mqtt5/mqtt5_pubsub/CMakeLists.txt
+++ b/samples/mqtt5/mqtt5_pubsub/CMakeLists.txt
@@ -22,4 +22,4 @@ endif ()
 
 find_package(aws-crt-cpp REQUIRED)
 
-target_link_libraries(${PROJECT_NAME} AWS::aws-crt-cpp)
+target_link_libraries(${PROJECT_NAME} AWS::aws-crt-cpp /usr/local/lib/libittnotify.a)

@GasparVardanyan
Copy link
Author

I build the sdk with -DBUILD_SHARED_LIBS=ON flag and I get libaws-c-iot.so.0unstable, libaws-c-s3.so.0unstable files in the lib folder. Then when I link the sdk to my project, compile and run, I get runtime errors related to that files.
I think the lib folder isn't a right place for ".so.0unstable" files.

In whole Arch+BlackArch package repos only in AWS sdk appear files like that:

-> [ ~ ] :: pkgfile -r 0unstable
extra/aws-c-s3
-> [ ~ ] :: cd -

@GasparVardanyan
Copy link
Author

The itt related error happens in samples as well. Currently this command helps to fix the problem and build the sdk and the samples (when ittapi library is located at /usr/local/lib/libittnotify.a):

rg --files | rg CMakeLists | xargs sed 's#\(target_link_libraries(.*\))$#\1 /usr/local/lib/libittnotify.a)#' -i

@bretambrose
Copy link
Contributor

I am not able to repro this using a container based on archlinux:latest.

If you can attach (as a file/download) the output you get from the initial cmake invocation with --trace-expand included on the command line that might give some useful information. The vtune integration is off by default based on this flag here: https://github.com/awslabs/aws-c-common/blob/main/cmake/AwsCFlags.cmake#L13

@bretambrose bretambrose added the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 2 days. label Jan 10, 2024
@GasparVardanyan
Copy link
Author

Output of cmake -DCMAKE_INSTALL_PREFIX=/home/gaspar/.local/tmp/sdk-workspace/aws-iot-device-sdk-cpp-v2 -DCMAKE_BUILD_TYPE=Debug --trace-expand ../aws-iot-device-sdk-cpp-v2: http://sprunge.us/ITCsgN

@github-actions github-actions bot removed the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 2 days. label Jan 11, 2024
@bretambrose
Copy link
Contributor

You appear to have a much older version of the library's cmake files installed in /lib but are building with newer submodules that expect that option to exist (and be off by default). In the output I see:

/lib/cmake/AwsCFlags.cmake(7):  include(CMakeParseArguments )
/lib/cmake/AwsCFlags.cmake(9):  option(AWS_ENABLE_LTO Enables LTO on libraries. Ensure this is set on all consumed targets, or linking will fail OFF )
/lib/cmake/AwsCFlags.cmake(10):  option(LEGACY_COMPILER_SUPPORT This enables builds with compiler versions such as gcc 4.1.2. This is not a 'supported' feature; it's just a best effort. OFF )
/lib/cmake/AwsCFlags.cmake(11):  option(AWS_SUPPORT_WIN7 Restricts WINAPI calls to Win7 and older (This will have implications in downstream libraries that use TLS especially) OFF )
/lib/cmake/AwsCFlags.cmake(12):  option(AWS_WARNINGS_ARE_ERRORS Compiler warning is treated as an error. Try turning this off when observing errors on a new or uncommon compiler OFF )
/lib/cmake/AwsCFlags.cmake(20):  function(aws_check_posix_lfs extra_flags variable )
/lib/cmake/AwsCFlags.cmake(48):  function(aws_set_common_properties target )

but the current version of AwsCFlags.cmake (which is in the submodules and linked above) is

include(CMakeParseArguments) # needed for CMake v3.4 and lower

option(AWS_ENABLE_LTO "Enables LTO on libraries. Ensure this is set on all consumed targets, or linking will fail" OFF)
option(LEGACY_COMPILER_SUPPORT "This enables builds with compiler versions such as gcc 4.1.2. This is not a 'supported' feature; it's just a best effort." OFF)
option(AWS_SUPPORT_WIN7 "Restricts WINAPI calls to Win7 and older (This will have implications in downstream libraries that use TLS especially)" OFF)
option(AWS_WARNINGS_ARE_ERRORS "Compiler warning is treated as an error. Try turning this off when observing errors on a new or uncommon compiler" OFF)
option(AWS_ENABLE_TRACING "Enable tracing macros" OFF)
option(AWS_STATIC_MSVC_RUNTIME_LIBRARY "Windows-only. Turn ON to use the statically-linked MSVC runtime lib, instead of the DLL" OFF)
option(STATIC_CRT "Deprecated. Use AWS_STATIC_MSVC_RUNTIME_LIBRARY instead" OFF)

@GasparVardanyan
Copy link
Author

I've installed some other aws libraries with package manager before building this sdk. After uninstalling that packages this sdk compiles without any errors.
Thank you for the help.

Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. p2 This is a standard priority issue
Projects
None yet
Development

No branches or pull requests

3 participants