C++ compile multiple definition
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-04-12 7:09 AM
Hi,
I have a C project, it compiles perfectly.
I changed the extension of main from main.c to main.cpp.
I use the function "Convert to C++", I did "Clean project"
but when I compile the project, I have a bulk of compiling error of this type:
C:/myproject/Debug/../Src/filex.c:62: multiple definition of `Function1'; ./Src/app_filex.o:C:/myproject/Debug/../Src/filex.c:62: first defined here
and this for every functions, I suppose.
Any suggestion?thank you
Solved! Go to Solution.
- Labels:
-
STM32CubeIDE
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-04-17 1:59 AM
At the end, I did the project from the beginning, starting directly as a C++ project, adding files by files starting from main, because no way to find the problem in the original project. Thank you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-04-12 7:13 AM
So take a look at those errors: they tell you where each of the multiple definitions is - look at those definitions.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-04-12 9:14 AM
I don't have more than one definition.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-04-12 9:38 AM
The errors say you do!
Post the full errors, and the source code to which they relate.
In both cases, use this button to post the text:
Copy & paste the errors from the 'Console' window.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-04-12 9:57 AM
Doesn't matter, the compiler thinks you do.
So either an include file is being pulled in recursively, and is not guarded against doing so, or you have actual definitions of code or variable in an include file.
Start with the first error, and understand why the compiler might be seeing things twice.
Get the tools to output a "Preprocessor Pass", and perhaps reviews that.
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-04-13 2:05 AM
@Tesla DeLorean wrote:Doesn't matter, the compiler thinks you do.
Indeed.
@Tesla DeLorean wrote:or you have actual definitions of code or variable in an include file.
@IVent.1 for example, see:
@Tesla DeLorean wrote:Start with the first error, .
Absolulutely.
@IVent.1 for this, you need to look in the 'Console' window - don't use the 'Problems' view, because that re-orders things.
Note that, when you have very many errors, the console view might "lose" the early ones.
See:
https://community.st.com/t5/stm32cubeide-mcus/sudden-error/m-p/658411/highlight/true#M25944
and:
https://community.st.com/t5/stm32cubeide-mcus/sudden-error/m-p/658427/highlight/true#M25950
and, for the location of the full log:
https://community.st.com/t5/stm32cubeide-mcus/sudden-error/m-p/658438/highlight/true#M25953
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-04-17 1:59 AM
At the end, I did the project from the beginning, starting directly as a C++ project, adding files by files starting from main, because no way to find the problem in the original project. Thank you.
