undefined reference to `memcpy' - eclipse

I strougle a little bit with my eclipse-arm-project. I get the following errors.
undefined reference to `__aeabi_uldivmod'
undefined reference to `memcpy'
I know the right gcc-lib is missing but I don't know which the right would be and how I could configure eclipse correct to use it.
At the moment I have this relating paths in my project-PATH-variable
C:\...\GNU Tools ARM Embedded\Build Tools\2.8-201611221915\bin (for make)
C:\...\GNU Tools ARM Embedded\5_4_2016q3\bin (for arm-none-eabi-gcc)
The 'Build tools folder' and the 'Toolchain folder' are the same as the second path from the both project-PATH-variable.
I tested a lot of stuff and am now totally confused, may I ask for a little help?

I found the Solution:
In the project settings ('C/C++ Build' -> 'Settings' -> 'Tool-Settings' -> 'Cross ARM C++ Linker' -> 'Gernal') the following flags were active and has to be deactivated.
Do not use default libraries (-nodefaultlibs)
No startup or default libs (-nostdlib)

Related

How to link to pistache in Eclipse C++

I fail to link the pistache library in Eclipse C++ on my Ubuntu machine. I already make this reference:
Properties > C/C++ Build > Settings > Tool Settings
Under GCC C++ Linker > Libraries > Library search path
Under GCC C++ Compiler > Includes > Include paths
Add /usr/local/include/pistache to each
It throws a bunch of errors like this:
.... undefined reference to `Pistache::Ipv4::any()'
Why does this fail? The autocomplete is able to see the reference when I try rewrite the whole line, but it still errors out.
You have to let the linker use shared libraries and pass the -fpic option to the compiler:
a. First step -shared, see this image
b. Last Step Position Independent Code -fPic, see this image
Update
Another way to solve this is:
a. Add support for pthread to the linker
b.Add pistache to libraries in the linker

How to compile without linking in Eclipse CDT

I am trying to build a small project to create a library of functions I use often.
I am expecting to do only the compiling without linking. So my end output should be a .o file and not an executable.
Any way to change this (I dont want to write a make file ).
At the moment, it is giving the below error since it is using -o and my project does not have a main.
(.text+0x20): undefined reference to `main'
collect2: error: ld returned 1 exit status
make: *** [util] Error 1
You have two options.
Create a "library project" via the "New" -> "Project..." wizard. Eclipse CDT will provide a default configuration that instructs the compiler to create an object file instead of an executable.
You can change the configuration of your existing project. To do this, right-click on your project, and select "Properties". Then, navigate to "C/C++ Build" -> Settings. Switch to the "Build Artifact"-tab, and change the "Artifact Type" to either "Shared Library" or "Static Library".
Hope this helps.

Programming Arduino with avrdude within Eclipse- cannot find -l/usr/avr

I am trying to program the Arudino Nano from Eclipse. It has the same processor as the Uno (Atmega328p). I have had this working before with the Uno, but have since gotten a new hard drive and had to reinstall/reconfigure everything. I am running Fedora 19 with Eclipse Kepler. I am getting an error in the build process that I don't even know where to start looking to solve, and Google hasn't been much help...
Here is the error:
make all
Building target: Arduino_Template.elf
Invoking: AVR C Linker
avr-gcc -Wl,-Map,Arduino_Template.map -mmcu=atmega328p -o "Arduino_Template.elf" ./Analog.o -l/usr/avr
/usr/lib/gcc/avr/4.8.2/../../../../avr/bin/ld: cannot find -l/usr/avr
collect2: error: ld returned 1 exit status
make: *** [Arduino_Template.elf] Error 1
17:29:38 Build Finished (took 124ms)
Has anyone encountered this before? Or does anyone have any suggestions?
Thanks.
The problem could be described like this:
First, the library should be specified only by its name and without the "lib" prefix and the ".a" suffix. The linker (this is where you get the error) will look for the library within the specified in the project paths and will add whatever is necessary to the file library name. So if the library you need is named mystuff it will look for a file named libmystuff.a.
In your case this is specified by the -l/usr/avr which I think could be misconfiguration or you did not copy/paste the entire error output. With the '-l' option you specify the name only, not the entire path to the file.
Second, the path should be specified, in the project configuration, where to look for the libraries, otherwise the linker will look for the library files only within your own project only. Often libraries are part of another project - so you need to adjust the project configuration accordingly.
I had similar problem and this is how I solved it ...
Go to menu Project/Properties. On left - choose "C/C++ Build". On right - choose the tab "Tool Settings". On the tree view choose "AVR C Linker" then "Libraries" sub-item. You are where you may need to make changes.
The list of "Libraries" is where you add libraries names, such as mystuff.
The Libraries Path is where you specify the paths to the libraries. This may look like this: "${workspace_loc:/mystuff/Release}"
The result of this is that the linker will look for this file: /mystuff/Release/libmystuff.a under you workspace root folder.

Threads in Eclipse AND c++11

My goal has been to create multi-threading programs, and I can not even get a simple thread
to execute ON ECLIPSE CDT. my Tools:
ECLIPSE 3.8.1 CDT
Ubuntu 13.10
I have noticed very similar issues regarding mine. I have tried those other solutions but I could not get them to work for me.
When I type the code in Eclipse CDT, Eclipse does not 'resolve' the symbols 'thread', however, It can find the header file 'thread'. 'Mutex' also does not resolve. Furthermore, after building, I run the program, eclipse returns :
"terminate called after throwing an instance of 'std::system_error'
what(): Enable multithreading to use std::thread: Operation not permitted"
Some additional notes:
I can compile and execute the code in the terminal using:
'clang++ c.cpp -pthread -std=c++11'
but...
'g++ c.cpp -pthread -std=c++11' compiles and
produces the same error as quoted above. So it looks like it's a compiler issue. I did
start to write the code in a new project within Eclipse CDT with the clang++ compiler and now that gives the same non-resolved 'thread' and produces the error as quoted above. So now I think I have some wrong settings, paths or flags set in Eclipse.
include <iostream>
include <thread>
using namespace std;
void p1(){
cout<<"process 1 is processing"<<endl;
}
int main() {
thread t1(&p1);
cout<<"Hello from main()"<<endl;
t1.join();
return 0;
}
I have been struggling with the very same issue and I finally resolved it. Here is what I did:
1) Add -std=c++11 for c++ build. To do that right-click your project, select properties and then: C/C++ Build -> Settings -> GCC C++ Compiler -> Miscellaneous(last option)
In other flags append -std=c++11. My Other flags now looks like: -c -fmessage-length=0 -std=c++11 but yours may be a bit different.
2) Add some linker options. In the same view(C/C++ Build -> Settings) as above select the GCC C++ Linker option and from there go to Miscellaneous(second to last option). Add the following Linker flags(the field was empty for me): -Wl,--no-as-needed -pthread. Hit apply.
3) Add a macro. Again from the project properties menu(project->right click->properties). Navigate to C/C++ General -> Paths and symbols -> Symbols. Select GNU C++. Add a symbol with the name __GXX_EXPERIMENTAL_CXX0X__ and no value. Again hit apply.
4) Navigate to C/C++ General -> Preprocessor Include paths.. Select the providers tab. In this tab leave only the following two options checked: CDT GCC Built-in Compiler Settings and CDT Managed Build Setting Entries. Select CDT GCC Built-in Compiler Settings uncheck the checkbox Share setting entries between projects(global provider) and now the text box labeled Command to get compiler specs should be enabled. In this text box append the good old -std=c++11. The text now looks like this for me ${COMMAND} -E -P -v -dD ${INPUTS} -std=c++11. Hit apply one last time.
5) Rebuild the index for the project. To do that right click the project->Index->Rebuild
Following these steps I was able to compile a c++11 multithreaded program, execute it and also Eclipse CDT did not report any errors and was helpful with the autocompletion. Unfortunately this setting has to be done separately for Release and Debug(or at least I have not found a way to share it). Hope this helps.

CURAND undefined reference error

I have pretty much the same problem as discussed in this question:
CURAND Library - Compiling Error - Undefined reference to functions
Namely, after having included cuda.h, curand.h and curand_kernel libraries, using
curandGenerator_t gen;
and
curandCreateGenerator(&gen, CURAND_RNG_PSEUDO_DEFAULT);
gives me the following error:
undefined reference to `curandCreateGenerator'
I am aware that this is a duplicate, but I really don't understand what should I do.
I'm using Nsight Eclipse on Ubuntu and I tried adding "-lcurand " to
Project Properties -> Build -> Settings -> Tool Settings -> NVCC Compiler -> Command
and I tried changing it to "nvcc -o RNG7 RNG7.cu -lcurand -Xlinker=-rpath,/usr/local/cuda/lib" as suggested, but nothing seems to work.
I'm a real newbie here, so a little detailed help would be appreciated, along with some reasons behind it, I prefer understanding things to quick fixes!
I got it, it was a very easy fix!
You need to go to:
Project Properties -> Build -> Settings -> Tool Settings -> NVCC Linker -> Libraries
and simply add a new library called "curand".