cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Did you know you can set a signature that will be added to all your posts? Set it here! X

Translate the entire conversation x

Creo Toolkit How to use external shared C libraries

AB_10248132
3-Newcomer

Creo Toolkit How to use external shared C libraries

Hello,

 

I need to make a toolkit that reads the information in an Excel file.

 

I found some libraries in C that does that and I'm trying to use one of them. The one I'm trying to use is LIBXLS (https://github.com/libxls/libxls)

This library doesn't give the compiled resources, you have to compile by yourself. After some effort I could compile the library using cygwin (gcc, make, etc...). 

At the end, I've got the .dll.a and the dll file and all the include files.
When I try to use the library in a C program and compile it using gcc, the library works fine.
But when I do the same thing to compile the toolkit, it doesn't work.

I tryed to use gcc to compile the toolkit, but I couldn't because it depends of some libraries and I'm getting an error when importing the visual studio library libcmt. But the library is not working when I compile the program using the default cl and link from nmake file.

 

What can I do to use the library inside the toolkit?

Or there is another option to read the excel file?

 

I'm using Creo 8.0.10

 

ACCEPTED SOLUTION

Accepted Solutions

Hello, I'm not very sure, but I think the problem is mixing the gcc compiler with the PTC TOOLKIT libs, what does not work (different compiler suites).
If you manage to compile a callable "support"-DLL file (with gcc), this could be the interface to call from your MSVC compiled TOOLKIT DLL (load the "support"-DLL at runtime, call its functions). But this seems too complicated to me, given that you use different compiler suites.
Alternatives:

  • find excel libraries, that can be used with MSVC (both C or C++ can be used)
    • The native, oldschool VB/VBA/COM and .NET Office API should still work (for Desktop Excel)
    • It is possible to use .NET (CRL/managed code) from within C++ (might be too complicated)
  • Write an external helper tool in any .NET language (where you can easily communicate to Excel), that recieves some commands and extracts data from a given Excel file, returning the result in a temporary CSV file (with correct unicode encoding and process exit codes to track error status). Not most beautiful/sophisticated solution, but it works.

I recommend to use the native/original Excel API (COM/.NET).

View solution in original post

4 REPLIES 4

Hi @AB_10248132 

Thank you for your question. 

Your post appears well documented but has not yet received any response. I am replying to raise awareness. Hopefully, another community member will be able to help.

Also, feel free to add any additional information you think might be relevant. It sometimes helps to have screenshots to better understand what you are trying to do.

 

Best regards,


Catalina
PTC Community Moderator
PTC

Hello, I'm not very sure, but I think the problem is mixing the gcc compiler with the PTC TOOLKIT libs, what does not work (different compiler suites).
If you manage to compile a callable "support"-DLL file (with gcc), this could be the interface to call from your MSVC compiled TOOLKIT DLL (load the "support"-DLL at runtime, call its functions). But this seems too complicated to me, given that you use different compiler suites.
Alternatives:

  • find excel libraries, that can be used with MSVC (both C or C++ can be used)
    • The native, oldschool VB/VBA/COM and .NET Office API should still work (for Desktop Excel)
    • It is possible to use .NET (CRL/managed code) from within C++ (might be too complicated)
  • Write an external helper tool in any .NET language (where you can easily communicate to Excel), that recieves some commands and extracts data from a given Excel file, returning the result in a temporary CSV file (with correct unicode encoding and process exit codes to track error status). Not most beautiful/sophisticated solution, but it works.

I recommend to use the native/original Excel API (COM/.NET).

Hello,

 

I really wasn't able to use the excel library.

Basically, I have to create my own library for this using Excel COM.

But it was not able to do in C, I had to change the project to C++.

 

Anyway, it was easier to start from scratch than making other libraries to work. But your suggestion to use COM saved me.

 

Thanks.

FV
17-Peridot
17-Peridot
(To:AB_10248132)

the first question is - are you sure you need xls reader and not  a modern xlsx.

if xls is indeed is what you need, then download a zip file from github, uncompress, add an empty c or c++ project in your  visual studio solution, use the same project settings as you had used for pro/toolkit projects, configure project's include path to point to the downloaded 'include' directory, add content of the downloaded 'src' directory to your project' 'source' folder (this is done in Visual Studio not in a file explorer), compile and link. If there are missing standard libraries - modify your project's linker->input configuration option to add them.

HIH

Announcements

Top Tags