having linker error developing in c++ using IAR and Renesas rx62n and Ucos III - c++

I purchased Michael Barr's embedded bootcamp training. It includes an IAR project that have all libraries configured. This project file is what all projects are created from. The code in project file are in c. I would like to develop in c++. There was an LCD library that I removed. The bsp and cpu files are all in c. I think there is a linking library for Ucos III theres a file in linker configuratuion called ucosIII.a . I can compile but I am getting linker errors:
Error[Li005]: no definition for "_CPU_IntDisMeasStart" [referenced from os_task.o(uCOS-III.a)]
Error[Li005]: no definition for "_CPU_IntDisMeasStop" [referenced from os_task.o(uCOS-III.a)]
Error[Li005]: no definition for "_CPU_TS_Update" [referenced from C:\embedded Bar grp\Exercises\RealtimeIObjects\Exercise1\Debug\Obj\os_cpu_c.o]
Error[Li005]: no definition for "_adc_isr" [referenced from C:\embedded Bar grp\Exercises\RealtimeIObjects\Exercise1\Debug\Obj\adcisr.o]

Related

Import error (E0337) while linking C++ and C++/CLI projects (.NET Core)

I am currently trying to set up a .NET project. I have a existing back project in c++ that I want to display on a web interface. To do this I am trying to link my C++ to the .NET platforme via a CLR Class Library .NET Core (and ultimately link that to an ASP.NET web interface but that is the next step).
My problem comes when I try to import the original files to the C++/CLI project. When the file I try to import uses C++ vectors (#include <vector>) I get eight errors all containing E0337 linkage specification is incompatible with previous "bsearch_s" (decalred at line 26) in the file corecrt_search.h (being a windows 10 kit file). You can see full content of the errors on this screenshot.
The other errors are respectively for functions qsort_s, bsearch, _lfind_s, _lfind, _lsearch_s, _lsearch and qsort at lines 35, 48, 64, 74, 83, 93 and 56.
No errors arise when I the imported file doesn't use vectors.
The file corecrt_search.h contains indeed two declaration of these functions each should be compiled in a different context. Here is a little extract of this file (hope this is enough).
_CRT_BEGIN_C_HEADER
_Check_return_
_ACRTIMP void* __cdecl bsearch(...);
// Managed search routines
#if defined __cplusplus && defined _M_CEE
extern "C++"
{
_Check_return_
void* __clrcall bsearch(...);
}
#endif
I don't understand why compiling the CLI project creates a conflict...
Here is how I linked the two projects:
I added the original project as a dependency to the CLR
In Linker => Input => Delay loaded Dlls, I added original_project.dll (usefull to add the ASP.NET project afterwards I think)
In C/C++ => General => Additional Include Directories, I added the path to the original project
I work on Visual Studio Community 2019 Version 16.4.2
Does anyone knows how to prevent such an error to occur? Thanks a lot!
I had the same issue. I was getting the same error when using
vector and Mat(OpenCV)
Its just the IntelliSense error. Seems to be a bug in IntelliSense.
I changed the mode to Build Only and the error was gone.

How to link a C project with a C++ static library(using opencv) in eclipse

I have created a c++ static library in eclipse which is using opencv.It is build fine and I want to include it in another c project in the same workspace.
Trying with
1)I have included library path in properties->c/c++ build->setting ->GCC C compiler ->Includes ->"path of project".
2)properties->c/c++ build->setting ->GCC C Linker-> Libraries ->Liraries(-i)->"Name of Lib"
3).properties->c/c++ build->setting ->GCC C Linker-> Libraries ->Liraries(-i)->"path of Lib"
But,this is not working while running the c project cannot find the static library functions giving error -"UNDEFINED REFERENCE TO THE FUNCTION"
Suggest a way to solve the problem.
Thanks in advance.
Got the answer.
These are the files needed to include
"${workspace_loc:/staticLibrary}"
MSDK/include
/IPP_Legacy/x64/include
Levmar/x64/include
/opencv/lib
opengl/x64/include/GL
Tesseract/x64/include/tesseract
freeGLUT/x64/include/GL
/ffmpeg/x64/include/libavcodec
compilers_and_libraries_2016.3.210/linux/ipp/include
compilers_and_libraries_2016.3.210/linux/mkl/include
compilers_and_libraries_2016.3.210/linux/tbb/include
compilers_and_libraries_2016.3.210/linux/daal/include
After these inclusion I faced a error of
/usr/lib/x86_64-linux-gnu/libstdc++.so.6: error adding symbols: DSO missing from command line
for which I got help from the link
http://i0.wp.com/omtlab.com/wp-content/uploads/2013/07/4.png
now the program is working all fine
Thank you

Eclipse paho mqtt C++ as dependency in another project

I have not much clue how c and c++ works at compile and runtime!
We are trying to use Eclipse Paho C++ library as a dependency in the project and messed up right now.
We have reffered to https://github.com/eclipse/paho.mqtt.cpp/tree/master/src/samples and used the same code in our project but we get this error.
error: 'mqtt' has not been declared class callback : public virtual mqtt::callback
We also have the following in place
Copied all the C and C++ libs(libmqttpp.so libpaho-mqtt3a.so.1.0 libpaho-mqtt3c.so.1 libmqttpp.so.0 libpaho-mqtt3as.so libpaho-mqtt3c.so.1.0 libmqttpp.so.0.1 libpaho-mqtt3as.so.1 libpaho-mqtt3cs.solibpaho-mqtt3a.so libpaho-mqtt3as.so.1.0 libpaho-mqtt3cs.so.1
libpaho-mqtt3a.so.1 libpaho-mqtt3c.so libpaho-mqtt3cs.so.1.0) to /usr/local/lib
Copied .h files(MQTTAsync.h MQTTClient.h MQTTClientPersistence.h) to /usr/local/include
Apart from above 2 steps, do I need to add anything to my project to resolve the problem or I am missing anything.
Finally, It worked after doing the following steps
Download 'C' zip from http://build.eclipse.org/technology/paho/
Copy lib files to /usr/lib/
Modified SConscript(alljoyn/gateway/gwagent/GatewatConnector/samples/) to extend LIBS - gwcnc_env.Prepend(LIBS = ['paho-mqtt3a', 'paho-mqtt3c', 'alljoyn_about', 'alljoyn_services_common', 'alljoyn_notification', 'alljoyn_config', 'alljoyn_gwconnector'])

How do I use arduino libraries with standard C code

I am using Eclipse kepler for AVR development.
The code that I have is C (Open Source), and I've gotten it adjusted so it runs perfectly. My target is an ATmega2560, in the form of an arduino mega2560.
Using the arduino board is strictly for hardware convenience; we are developing the hardware to be a custom board with most of the core arduino mega2560 components.
I need to use several libraries with this project that are only available as arduino libraries, namely libraries for an e-paper screen (from seeedstudio) and Nordic's BLE nRF8001.
If I create a new arduino project using the plugin in eclipse, I can build and run the tests for the arduino libraries perfectly.
When I try to merge the 2 code bases together, I can't seem to call the functions in the added arduino libraries - if I call them the compiler throws a linking error.
Building target: Virgin2ManualArdInsert.elf
Invoking: AVR C Linker
avr-gcc -Wl,-Map,Virgin2ManualArdInsert.map -mmcu=atmega2560 -o "Virgin2ManualArdInsert.elf" ./avr/adc.o ./avr/eeprom.o ./avr/lcd_and_input.o ./avr/main.o ./avr/strings.o ./avr/unimplemented.o ./avr/usart.o ./aes.o ./baseconv.o ./bignum256.o ./ecdsa.o ./endian.o ./fft.o ./fix16.o ./hash.o ./hmac_sha512.o ./messages.pb.o ./p2sh_addr_gen.o ./pb_decode.o ./pb_encode.o ./pbkdf2.o ./prandom.o ./ripemd160.o ./sha256.o ./statistics.o ./stream_comm.o ./test_helpers.o ./transaction.o ./wallet.o ./xex.o
./avr/main.o: In function `main':
main.c:(.text.startup.main+0xc): undefined reference to `writeEink'
collect2: error: ld returned 1 exit status
makefile:53: recipe for target 'Virgin2ManualArdInsert.elf' failed
make: *** [Virgin2ManualArdInsert.elf] Error 1
As a test, I'm just trying to call a basic "write to display" call in eInk.cpp from main.c:
extern "C"{
void writeEink()
{
EPAPER.begin(EPD_SIZE); // setup epaper, size
EPAPER.setDirection(DIRNORMAL); // set display direction
eSD.begin(EPD_SIZE);
GT20L16.begin();
// int timer1 = millis();
EPAPER.drawString("testing", 10, 10);
EPAPER.drawNumber(12345, 60, 40);
EPAPER.drawFloat(-1.25, 2, 80, 65);
EPAPER.display(); // use only once
}
Is a static library built from the arduino cores the way to go here? I've tried it (though it seems most of the procedures are outdated) and the libraries do not want to link/be called.
What is the correct procedure for including C++/Arduino calls in my C code?
I've tried using extern "C" {function()}; in my .cpp files and .h files but to no use.
Thank you for any help or pointers to where I can figure it out for myself.
You can try to compile your C code as C++ by simply renaming the files to *.CPP, but chances are that you have to modify your code to make it compile as C++ code. There are things that are allowed for C, but not for C++ (like calling functions that are not declared).
The other solution is to wirte wrappers around the C++ functions that you want to use from C.
You have to consider two limitations of C against C++:
C is not object oriented
C does not support overloading of functions
This example for Serial.print() shows how you can handle this with a wrapper:
extern "C" void SerialPrintInteger( int value )
{
Serial.print( value );
}
In this example you would write similar functions like SerialPrintFloat(), SerialPrintString() etc.
The extern "C" prefix tells the compiler to create the function in a way that makes it callable from C.
The error you received above isn't a compiler error, it's a linker error. I haven't used Eclipse for Arduino development, I just stick with the Arduino IDE, but the standard Arduino projects expect all of your code to be in a single source file, which it compiles and then links with the Arduino libraries. Arduino programs don't have a C/UNIX-style "main" function, the standard functions are "setup" and "loop."
I recommend going back to one of the Arduino example programs, blink for instance, and watching the console log as Eclipse compiles and links the program. What's happening here is:
The C/C++ compiler compiles your source code, including setup(), loop(), and any other functions you have created, into an object file.
The Linker links this single object file with the Arduino runtime, and any Arduino libraries you have specified. The output of this is an image of the program, in your example above it's trying to make 'Virgin2ManualArdInsert.elf'.
The uploader (probably avrdude) loads this image into your Arduino and resets it.
The Arduino comes out of reset and runs your new code.
If your program is reasonably small, say not more than a few hundred lines, just put all the functions in the one source file, then you won't have to learn how to drive the linker.
If you need, for some reason, to have the sources in a separate file (maybe they're shared with another program, or another platform), then you'll have to learn how to get Eclipse to link the object files from your multiple source files. This may just involve adding the sources into your Eclipse project properly, or you may have to write a Makefile or something similar.
As for C vs C++ source code, you can usually drop a C function into a C++ source file and compile it. There are a few differences, but this way you don't need to worry about "C" linkage or any of that silliness.

C++; eclipse linker error

So working on getting my eclipse IDE going so I can develop my arduino uno in eclipse.
My C++ is weak so this is probably a nube error on my part.
I have a blink program that looks for an arduino library I compiled from the arduino IDE's library.
My code points to the header file and my code find it fine; meaning I can click on:
#include <arduino.h>
and go view the header
this: "C:/programs/arduino-1.0/hardware/arduino/cores/328p_lib/libuno_library.a"
is a valid path... but I get the following error:
>****** Build of configuration Debug for project project1 ****
>make all
>Building target: project1.elf
>Invoking: AVR C++ Linker
>avr-g++ -Wl,-Map,project1.map,--cref -L"C:\programs\arduino->1.0\hardware\arduino\cores\328p_lib" -mmcu=atmega328p -o "project1.elf" ./code/code1.o >-l"C:/programs/arduino-1.0/hardware/arduino/cores/328p_lib/libuno_library.a"
>c:/programs/winavr/bin/../lib/gcc/avr/4.3.3/../../../../avr/bin/ld.exe: cannot find ->lC:/programs/arduino-1.0/hardware/arduino/cores/328p_lib/libuno_library.a
>make: *** [project1.elf] Error 1
>**** Build Finished ******
Well after wasting 2 days or so of fun time I finally found the problem.
http://sourceforge.net/projects/avr-eclipse/forums/forum/664382/topic/4640554
When adding the static library to the linker you have to remove the lib prefix and the .a suffix. not sure what that is about.
Right click on the project>Click on C/C++ BUild> Settings > GCC C++ Linker> Libraries
Click the first icon Add> Add the library name ( without the .a suffix, the suffix will be added automatically)
This will ensure that the library is added to the project.
If the library is part of another project >Go to GCC C Compiler> directories >Add the directory
This will ensure that the library is there for getting the compilation done.