Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » Adding a DLL to a C project for an embedded system
Adding a DLL to a C project for an embedded system [message #1707462] Fri, 04 September 2015 20:44 Go to next message
Christopher Koch is currently offline Christopher KochFriend
Messages: 4
Registered: September 2015
Junior Member
I posted this in the newcomer forum and was directed here. Please see below for my inquiry. Thank you.

> I am working on a project where my goal is to create a binary file (not
> an executable) from C code to flash into a microcontroller in order for
> the system to act as a MQTT client. I am using PAHO as the backbone for
> the MQTT Client and have downloaded and compiled the .dll and .lib files
> for the MQTT client using Microsoft Visual Studio 15.0. I have taken
> the MQTTClient.h file and included it in my eclipse project. Now I am
> trying to figure out how to link the .lib and/or .dll to the project so
> that I can compile the C code and generate the binary file to flash to
> my embedded system. I have tried a few different ways to do this but am
> not sure where in the make file to include the library or .dll. Below
> is my current output:
>
> 10:05:13 **** Build of configuration Default for project DSM_demo****
> mingw32-make debug C:/Workbench/make\mingw32-make.exe -C
> C:/Workbench/SDK/make -j debug make\mingw32-make.exe[1]: Entering
> directory 'C:/Workbench/SDK/make'
> make\mingw32-make.exe[1]: Nothing to be done for 'debug'.
> make\mingw32-make.exe[1]: Leaving directory 'C:/Workbench/SDK/make'
> [ LD ] exe/SDS.out
> build/MQTTSyncPub.o: In function `MQTTSyncPub':
> C:\Workbench\workspace\DSM_demo\make/../MQTTSyncPub.c:76: undefined
> reference to `MQTTClient_create'
> Makefile:94: recipe for target 'exe/SDS.out' failed
> C:\Workbench\workspace\DSM_demo\make/../MQTTSyncPub.c:81: undefined
> reference to `MQTTClient_connect'
> C:\Workbench\workspace\DSM_demo\make/../MQTTSyncPub.c:90: undefined
> reference to `MQTTClient_publishMessage'
> C:\Workbench\workspace\DSM_demo\make/../MQTTSyncPub.c:94: undefined
> reference to `MQTTClient_waitForCompletion'
> C:\Workbench\workspace\DSM_demo\make/../MQTTSyncPub.c:96: undefined
> reference to `MQTTClient_disconnect'
> C:\Workbench\workspace\DSM_demo\make/../MQTTSyncPub.c:97: undefined
> reference to `MQTTClient_destroy'
> collect2.exe: error: ld returned 1 exit status
> mingw32-make: *** [exe/SDS.out] Error 1
>
> Any help would be greatly appreciated. I am sorry if I haven't given
> enough information, please let me know anything else I need to include
> to help solve this issue.
>
> Thank you in advance,
> Chris
Re: Adding a DLL to a C project for an embedded system [message #1707464 is a reply to message #1707462] Fri, 04 September 2015 21:28 Go to previous messageGo to next message
Tauno Voipio is currently offline Tauno VoipioFriend
Messages: 742
Registered: August 2014
Senior Member
A DLL is a Windows thing. It has to reside together with a copy of Windows on the processor running the code using it. It is actually a special kind of Windows executable, with external access points built in. Do you have Windows on the microcontroller?

To do anything useful, the binary on the microcontroller has to be executable by its processor. What do you mean with 'not an executable'?


--

Tauno Voipio
Re: Adding a DLL to a C project for an embedded system [message #1707472 is a reply to message #1707464] Sat, 05 September 2015 01:15 Go to previous messageGo to next message
David VavraFriend
Messages: 1426
Registered: October 2012
Senior Member
This doesn't sound like an issue associated with CDT or the IDE itself. I guess you were directed here because your question has something to do with C.

It's not completely clear what you are attempting to achieve. I'm assuming you want to generate a binary image for a microcontroller vs. a .exe formatted file. Normally the code for a microcontroller or an embedded processor would be self-contained and stand-alone. A DLL is a shared library and to use it requires runtime intervention. They are similar to .so files in linux which would require loading it into the microcontroller as well as your image.

I've done a lot of embedded work myself although I've not used your specific tools so can't tell you specifically how to proceed. You often would need a special linker or other tool to convert your object code into the image. I assume you already have that and know how to use it.

You probably want to use a statically linked library vs. depending on a DLL , though, so that all code is contained within the image file, This will avoid any need for an external relocatable library. My guess is that whatever is generating exe/SDS.out wants all calls to be resolved within the image. A statically linked library should achieve this.


HTH

EDIT:
Reread your question, you said: "Now I am trying to figure out how to link the .lib and/or .dll to the project ... I have tried a few different ways to do this but am not sure where in the make file to include the library or .dll."


The more pertinent question is how does whatever is producing the binary know where the lib files are?

Where did the makefile come from?
Does eclipse generate it or was it produced externally?

If it's Eclipse that generates the makefile then you should look at the tool settings in C/C++ Project Properties ==> Build ==> Settings ==> Tool Settings tab which allows you to configure individual commands that appear in the makefile recipes.

http://help.eclipse.org/mars/index.jsp?topic=%2Forg.eclipse.cdt.doc.user%2Freference%2Fcdt_u_prop_build_settings_tool.htm

If the makefile was produced externally, you need to examine the recipe that generates the binary image to determine how the files are linked.

[Updated on: Sat, 05 September 2015 14:15]

Report message to a moderator

Re: Adding a DLL to a C project for an embedded system [message #1708212 is a reply to message #1707472] Mon, 14 September 2015 16:21 Go to previous messageGo to next message
Christopher Koch is currently offline Christopher KochFriend
Messages: 4
Registered: September 2015
Junior Member
Thank you both for your replies.

Tauno, by not an executable, I did mean as David assumed that I am not generating an .exe file from eclipse but rather a .bin file that will be downloaded into the embedded microcontroller (uC) to run the code. An no I don't have windows running on the uC, but am using FreeRTOS.

David, I will try and figure out the makefile issue. I normally use a makefile that was produced externally. I will see if I can figure out how to link the .lib file through this. I have also had an issue with the other option of letting eclipse automatically generate the makefile, it always fails saying something like:

makefile:154: recipe for target 'clean' failed
or
mingw32-make: *** No rule to make target 'debug'. Stop.

Thanks again,

Chris

[Updated on: Mon, 14 September 2015 16:26]

Report message to a moderator

Re: Adding a DLL to a C project for an embedded system [message #1708218 is a reply to message #1708212] Mon, 14 September 2015 17:01 Go to previous messageGo to next message
David VavraFriend
Messages: 1426
Registered: October 2012
Senior Member
makefile:154: recipe for target 'clean' failed

That's just saying something went wrong during "make clean". For clean operations this often arises when trying to delete non-extant files. If this is the case then "rm -f" would fix this. But I don't let Eclipse generate the make files so can't be sure how to fix it.

Same with the missing target "debug". If Eclipse is generating the make file, it seems odd it would try to use a target it failed to create. However, this also occurs when using automake when it isn't configured properly. But then, if automake is in use, it is the generator of the make file.

Perhaps someone else can help here.

[Updated on: Mon, 14 September 2015 17:02]

Report message to a moderator

Re: Adding a DLL to a C project for an embedded system [message #1708230 is a reply to message #1708212] Mon, 14 September 2015 19:00 Go to previous messageGo to next message
Tauno Voipio is currently offline Tauno VoipioFriend
Messages: 742
Registered: August 2014
Senior Member
Christopher Koch wrote on Mon, 14 September 2015 19:21
Thank you both for your replies.

Tauno, by not an executable, I did mean as David assumed that I am not generating an .exe file from eclipse but rather a .bin file that will be downloaded into the embedded microcontroller (uC) to run the code. An no I don't have windows running on the uC, but am using FreeRTOS.

(-- quote stripped by TV --)

Chris


This means that you cannot use the DLL in the target processor. A DLL is a special format Windows executable with entry points to exported functions, and your target microprocessor does not understand a bit of it.

You may be out of luck, unless there is a C source that compiles to something linkable to your target (The Windows source may be written so that it does not make sense in your microprocessor).


--

Tauno Voipio
Re: Adding a DLL to a C project for an embedded system [message #1708236 is a reply to message #1708230] Mon, 14 September 2015 19:48 Go to previous message
David VavraFriend
Messages: 1426
Registered: October 2012
Senior Member
Don't know if this is any help but it seems RTOS can use embedded Windows DLLs and even DLLs in the RTOS file system.

RTOS DLL support:
http://www.on-time.com/rtos-32-docs/rttarget-32/programming-manual/advanced-topics/using-dlls-through-rtloc/


I suspect FreeRTOS does as well but a quick search didn't turn up any pages that are as explicit as the one I linked here. Perusing the RTOS and FreeRTOS documentation will probably enlighten you on the proper way to link libraries with your code. Once you know how to do that then you likely will know what to look for to get Eclipse to do it for you.


Previous Topic:MinGW and Cygwin GCC is not functioning
Next Topic:google tests runner
Goto Forum:
  


Current Time: Fri Apr 26 19:04:19 GMT 2024

Powered by FUDForum. Page generated in 0.03072 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top