CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Linker error: dyn mem mis-match true!=false

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
allenhuffman



Joined: 17 Jun 2019
Posts: 552
Location: Des Moines, Iowa, USA

View user's profile Send private message Visit poster's website

Linker error: dyn mem mis-match true!=false
PostPosted: Mon Jun 17, 2019 12:28 pm     Reply with quote

I keep getting myself in a spot where my builds stop working with an odd linker error:

Linking to FlashLogger.hex on 17-Jun-19 at 13:24
*** Error 146 "C:\(path here)\$linker.c" Line 5(8,14): Import error dyn mem mis-match true!=false
*** Error 146 "C:\(path here)\$linker.c" Line 5(8,29): Import error
2 Errors, 0 Warnings.
Build Failed.

I found a few references to this in the forum, but nothing that seemed to explain to me what causes it.

I am doing a multi-file test program with FOUR .c files. I do not understand the compiler architecture enough yet to understand what's going on. I suppose I'll learn more once I've been using it more than a week.

Anyone have any tips on where I can look? I did not find anything helpful in the Help file for this linker (?) error.

Thanks!
dluu13



Joined: 28 Sep 2018
Posts: 395
Location: Toronto, ON

View user's profile Send private message Visit poster's website

PostPosted: Mon Jun 17, 2019 12:31 pm     Reply with quote

What IDE are you doing this in?

If you are doing this in MPLAB then you will need to put those .c files under "header files" in your project. Then you will need to #include the .c files in your main file.

At least this is what I think is going on.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Jun 17, 2019 12:32 pm     Reply with quote

It seems to me that you're trying to do multiple advanced things while
still a newbie on CCS. That's not a good idea.

Regarding your errors, see this thread. One guy at the end says
he has a solution.
http://www.ccsinfo.com/forum/viewtopic.php?t=45074
But if I were you, I would just not do this stuff now.
allenhuffman



Joined: 17 Jun 2019
Posts: 552
Location: Des Moines, Iowa, USA

View user's profile Send private message Visit poster's website

PostPosted: Mon Jun 17, 2019 12:33 pm     Reply with quote

dluu13 wrote:
What IDE are you doing this in?

If you are doing this in MPLAB then you will need to put those .c files under "header files" in your project. Then you will need to #include the .c files in your main file.

At least this is what I think is going on.


I am using "PIC C Compiler." (Listed as "PCDIDE Compiler" in the About dialog box.)


Note that, sometimes, it works just fine. Then it won't work. Reboots, relaunches, etc. change the behavior. It just looks (to me) like it's a buggy IDE.
allenhuffman



Joined: 17 Jun 2019
Posts: 552
Location: Des Moines, Iowa, USA

View user's profile Send private message Visit poster's website

PostPosted: Mon Jun 17, 2019 12:40 pm     Reply with quote

PCM programmer wrote:
It seems to me that you're trying to do multiple advanced things while
still a newbie on CCS. That's not a good idea.

Regarding your errors, see this thread. One guy at the end says
he has a solution.
http://www.ccsinfo.com/forum/viewtopic.php?t=45074
But if I were you, I would just not do this stuff now.


I sure hope using multiple .c files isn't a problem for this IDE. Our main projects use tons of .c files, so it seems possible. (And I certainly don't consider using four tiny .c files to be an advanced programming technique Smile

Sometimes I can build and load it just fine. Other times, I get a number of errors and issues. Same code. Very flaky results. Sometimes just closing and reopening the IDE "fixes" it. But I keep seeing certain things pop up again and again.

I'm no stranger to IDE issues, having worked with Renesas, IAR, Eclipse, etc. so I expect I'll be in good shape once I learn the quirks of this one.
dluu13



Joined: 28 Sep 2018
Posts: 395
Location: Toronto, ON

View user's profile Send private message Visit poster's website

PostPosted: Mon Jun 17, 2019 12:42 pm     Reply with quote

I use plenty of c files as well. However, CCS is a single pass compiler so then you have to #include the .c files as the top of your main c file rather than just the .h files.

If you look at the examples in the examples folder of the CCS installation, you can find some instances of including the .c files.
allenhuffman



Joined: 17 Jun 2019
Posts: 552
Location: Des Moines, Iowa, USA

View user's profile Send private message Visit poster's website

PostPosted: Mon Jun 17, 2019 12:43 pm     Reply with quote

PCM programmer wrote:

Regarding your errors, see this thread. One guy at the end says
he has a solution.
http://www.ccsinfo.com/forum/viewtopic.php?t=45074
But if I were you, I would just not do this stuff now.


I ended up in that thread earlier. The suggestion at the end to add:

Code:
#USE DYNAMIC_MEMORY


…did make it build. It reminds me of some of the odd workarounds for the Arudino IDE to make things link when the preprocessor is trying to be smart ;-)
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Jun 17, 2019 12:53 pm     Reply with quote

Are you using "Multiple Compilation Units" ? That's an advanced topic.
The standard way to use CCS is to have only one file (your main .c file)
listed in the project files. Then add other files by using #include
statements in your main .c file. This method is pretty reliable.
allenhuffman



Joined: 17 Jun 2019
Posts: 552
Location: Des Moines, Iowa, USA

View user's profile Send private message Visit poster's website

PostPosted: Tue Jun 18, 2019 8:32 am     Reply with quote

PCM programmer wrote:
Are you using "Multiple Compilation Units" ? That's an advanced topic.
The standard way to use CCS is to have only one file (your main .c file)
listed in the project files. Then add other files by using #include
statements in your main .c file. This method is pretty reliable.


Yes, all our projects use Multiple Compilation Units. These are existing projects that have been around for years. I am just trying to make small, test code to learn how the IDE works.

I don't know what is in my code that is triggering the need for Dynamic Memory, but I am happy with the workaround/solution.
allenhuffman



Joined: 17 Jun 2019
Posts: 552
Location: Des Moines, Iowa, USA

View user's profile Send private message Visit poster's website

PostPosted: Mon Jul 15, 2019 11:22 am     Reply with quote

For future reference... I've been making a list of things that can cause this, and will add them here:

Using the #include <time.h> files will include <stdlibm.h> and cause this.
_________________
Allen C. Huffman, Sub-Etha Software (est. 1990) http://www.subethasoftware.com
Embedded C, Arduino, MSP430, ESP8266/32, BASIC Stamp and PIC24 programmer.
http://www.whywouldyouwanttodothat.com ?
Ttelmah



Joined: 11 Mar 2010
Posts: 19518

View user's profile Send private message

PostPosted: Tue Jul 16, 2019 8:57 am     Reply with quote

What is strange though is that "stdlibm.h", should already be adding
the #USE DYNAMIC_MEMORY.

This is _required_ if you are using the dynamic memory functions, unless
you are manually setting the parameters for this. In stdlibm.h, we have:

Code:

#if !defined(STDLIBM_MANUAL_DYNAMIC_MEMORY)
   #USE DYNAMIC_MEMORY
#endif


The error is occurring because if you use MCU's, and this include is not
in _all_ the components, you can get a function called from a module
that does not define this, so does not have the extra variable created that
the dynamic memory functions use. Hence the issue....
allenhuffman



Joined: 17 Jun 2019
Posts: 552
Location: Des Moines, Iowa, USA

View user's profile Send private message Visit poster's website

PostPosted: Tue Jul 16, 2019 10:08 am     Reply with quote

Ttelmah wrote:
What is strange though is that "stdlibm.h", should already be adding
the #USE DYNAMIC_MEMORY.


CCS said to be use to have the "#use DYNAMIC_MEMORY" in every file. I would think just adding it to the master .h generated by the Project Wizard would be enough.

My original problem was before I was using any of the <time.h> functions, so at some point I'll go revisit that project and see what I can find.
_________________
Allen C. Huffman, Sub-Etha Software (est. 1990) http://www.subethasoftware.com
Embedded C, Arduino, MSP430, ESP8266/32, BASIC Stamp and PIC24 programmer.
http://www.whywouldyouwanttodothat.com ?
Ttelmah



Joined: 11 Mar 2010
Posts: 19518

View user's profile Send private message

PostPosted: Wed Jul 17, 2019 12:25 am     Reply with quote

Yes.

I think they mean that #USE DYNAMIC_MEMORY, needs to be present in
every compiled 'part'. So each 'compilation unit' must have it in. So each .o
file must have been compiled with this setting.
So each 'file' here is each .o file, not each file of your project.
It makes total sense once you think about how dynamic memory is handled.
allenhuffman



Joined: 17 Jun 2019
Posts: 552
Location: Des Moines, Iowa, USA

View user's profile Send private message Visit poster's website

PostPosted: Thu Nov 07, 2019 10:59 am     Reply with quote

UPDATE:

Code:
#case


...forces the compiler to be case sensitive. This removed this error from a project I had today. Once the error appeared, I could not build again until I shut the program down and restarted it.
_________________
Allen C. Huffman, Sub-Etha Software (est. 1990) http://www.subethasoftware.com
Embedded C, Arduino, MSP430, ESP8266/32, BASIC Stamp and PIC24 programmer.
http://www.whywouldyouwanttodothat.com ?
afk_pic



Joined: 02 Jun 2020
Posts: 19

View user's profile Send private message

PostPosted: Tue Sep 01, 2020 7:35 am     Reply with quote

allenhuffman wrote:
UPDATE:

Code:
#case


...forces the compiler to be case sensitive. This removed this error from a project I had today. Once the error appeared, I could not build again until I shut the program down and restarted it.


Gracias/Thank you!!!!

This works for me!
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group