Ti include curl/ a third party library in Torizon C/C++ application

I tried to include curl, a third party library into a Visual Studio C/C++ application project with the target Colibri IMX6DL
I created an C/C++ Torizon embedded project in VS2019 following the steps in Build and Run your First C Application. It built and ran alright.
With the same project, I did the following steps mimicking steps in C/C++ Development and Debugging on Torizon Using Visual Studio | Toradex Developer Center.
Step 1: in Project > Properties-> Configuration Properties > C/C++ > General->Additional Include Directories, it has got “%(ClCompile.AdditionalIncludeDirectories)” (the default)
Step 2: Set the C++ language to v11. (the default; same as C”
Step 3: In Configuration Properties > Linker > Input-> Library Dependencies, it has got “curl”.
Step 4: In Torizon C/C++ application->Configuration->.\appconfig_0->->devpckages, it has got “libcurl4-openssl-dev:armhf”
Step 5: likewise, n Torizon C/C++ application->Configuration->.\appconfig_0->->extra pages, it has got “libcurl4”
When I did rebuild, I obtained the following display On the Output pane -
1>------ Build started: Project: TorizonApp8, Configuration: Debug_debian_arm32v7_bullseye x64 ------
1>Torizon Container Build
1>Containers are up to date.
1>Validating sources
1>Copying sources remotely to ‘127.0.0.1’
1>Validating architecture
1>Validating architecture
1>Starting remote build
1>Compiling sources:
1>main.cpp
1>Linking objects
1>/usr/lib/gcc-cross/arm-linux-gnueabihf/10/…/…/…/…/arm-linux-gnueabihf/bin/ld : error : cannot find -lcurl
1>collect2 : error : ld returned 1 exit status
1>Done building project “TorizonApp8.vcxproj” – FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Question:

  1. What step(s) have I missed? (I did see curl in /usr/bin directory.)
  2. If I should invoke curl API in my source code, will compiler able to find curl.h if I do
  3. #include <curl.h>

Thanks,

Greetings @MichaelFang,

I was unable to reproduce this on my end. I had the statement #include <curl/curl.h> in my code and it was able to find and link the curl library fine. Can you double check your project properties changes and make sure they’re being applied to all configurations and platforms.

Additionally in Visual Studio can you do Build -> Update Torizon SDK Container. Usually when you add new libraries the SDK container should update itself but sometimes you’ll need to manually update it to make sure. While it’s updating you should see in the output pane what packages it’s including, make sure libcurl4-openssl-dev:armhf is one of them.

Finally as an additional measure if none of the above works, can you enable the debug console as shown here: Visual Studio Extension For Torizon | Toradex Developer Center

Once enabled can you re-run through your entire process again, then provide me with the output in the debug console.

Best Regards,
Jeremias

I manually did "Build → Update Torizon SDK Container, and Output pan shows -
Step 2/2 : RUN apt-get -q -y update && apt-get upgrade -q -y && apt-get -q -y install gdb rsync libcurl4-openssl-dev:armhf && rm -rf /var/lib/apt/lists/*

Which seems to have solved the problem. After that, the rebuild is successful. Thanks!

Huh strange that the SDK container didn’t rebuild itself automatically, but glad we were able to resolve this.

Best Regards,
Jeremias