LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

How to include the libcurl library into Labwindows?

Hello everyone,

I have already seen that some questions have been asked here and there about the topic of curl library. I am trying to get acces to a cloud website and I already found the curl library that I downloaded and included in my CVI code. The problem now is that there are a lot of Header files that are not to be found and there are tons of them so it is basically impossible to download each of the missing header files for the code.

The code that I actually want to impelement in my CVI project is discussed here:

https://stackoverflow.com/questions/2329571/c-libcurl-get-output-into-a-string/2329792#2329792

Is there any way how I can find or use a library that is nearly impossible to compeletely download?

Thanks a lot in advance..

 

0 Kudos
Message 1 of 7
(2,022 Views)

You should not download individual files from a project, definitely not a project like libcurl. Instead you need to download a package. There are usually two sort of packages for Open Source projects like libcurl.

 

- A development package contains all the header files (usually in a folder called include), the import link libraries (for both 32-bit and 64-bit compilation seperately often in directories called lib32 and lib64 but it could also just be a lib directory with the 32-bit and 64-bit designation being part of the library name) and last but not least the DLLs (also in both bitnesses). Alternatively the package may also contain static libraries instead of DLLs with according import libraries. 

 

- A source code package contains also all the header files and in addition to that also the source code files (usually in a folder called src or source). It may or may not contain the build products (DLLs and import libraries and/or static libraries), additional documentation and unit tests, test projects and whatever else the developers deemed interesting.

 

For your purpose you usually want to get a development package. You then need to add the include directory and the correct library directory of that package to your CVI project, and then add the necessary #include statements to your source code files.

Rolf Kalbermatter
My Blog
Message 2 of 7
(1,986 Views)

Hello! i'm doing the same job, i need to use cURL in my project, have you solved this problem?

i've tryed to do a wrapper but it gives me error in calling convention.

if i you the library without the wrapper there is no .lib but a .a library file and it's impossible to call the library.

attached my example project, with both the test.

 

now i'm thinking to bypass the problem calling cURL with system ("cmd.exe /c curl ... > result.json) forcing the command prompt to save the result in a file and then i will read this file.

it's not the fastest way but get the job done and with nvme ssd it's not slowing down the software so much.

Davide Vittorio G. - TLGB S.R.L.
Italian SW Developer
0 Kudos
Message 3 of 7
(1,828 Views)

ok, I've got it work!

 

the error in my wrapper is that I've declared the function as stdcall but this dll is cdecl.

just change it and it works!

Davide Vittorio G. - TLGB S.R.L.
Italian SW Developer
0 Kudos
Message 4 of 7
(1,813 Views)

Hi @holly7877

 

I saw the project you attached.

  • Do you mean you changed __stdcall to __cdecl into curl_wrapper.h to run the example successfully?
  • Did you download curl binaries for Windows from curl for Windows?
Vix
-------------------------------------------
In claris non fit interpretatio

-------------------------------------------
Using LV from 7
Using LW/CVI from 6.0
0 Kudos
Message 5 of 7
(1,562 Views)

Hi @vix

 

actually I don't rember every step I've done but I can attache you this sample project that wrap the .dll and get the example.com website

Davide Vittorio G. - TLGB S.R.L.
Italian SW Developer
Message 6 of 7
(1,556 Views)

@vix wrote:

Hi @holly7877

 

I saw the project you attached.

  • Do you mean you changed __stdcall to __cdecl into curl_wrapper.h to run the example successfully?
  • Did you download curl binaries for Windows from curl for Windows?

libcurl comes with its own header file. You need to make sure to include the correct header file in your own C project file and make sure to have the right preprocessor defines declared in one of your own headers that is included before te libcurl headers or in your project configuration so that the libcurl header uses the right internal preprocessor defines for the platform you are working on.

libcurl being a multiplatform project will be compiled in many different flavors, at least one per platform and potentially even more. If you want to use precompiled shared libraries you need to make sure that your compiler uses the same definitions than what was used to compile the shared library or you end up into crashing your system.

 

LabWindows/CVI tries to use the same definitions as Visual C but being a clang based compiler also has some GNUisms in there and then some of its own. So if the libcurl headers aren't fully cleanly written they might get into a mixup about on what compiler and platform they are compiled for.

 

This is the main work you have to do when interfacing to other libraries. Not funny work, unavoidable but definitely doable. Changing the header files of a shared library to make it work is definitely not the right solution.

Rolf Kalbermatter
My Blog
0 Kudos
Message 7 of 7
(1,539 Views)