Using Eclipse with a pre-existing C Makefile - c

I wrote a makefile which works fine in shell (ubuntu), but I can't manage to run it from eclipse.
I created a makefile in eclipse, which is seen under DEBUG directory of the relevent project.
In Run/Debug settings I defined in Main tab in C Application: Debug/projectname, and in Project: projectname, Build configuration:Debug. (which now I see it gives me an error of not executable file so I change it to the main.o file).
in C/C++ Build , in Builder Settings I checked use default build command and unchecked Generate Makefiles Automatically. Build directory is ${workspace_loc:/projectname}
What should I do now? How make command can be run?
What is make target? I tried to create one and then build it, but I don't see how it connects to my makefile. Should make target be done from view target of from right click on the project?
From make target view I created new target and when I do 'build target' I get
make mat
make: *** No rule to make target `main.c', needed by `main.o'. Stop.
So it seems to read the right makefile, but what is "No rule to make target `main.c' "? the makefile is:
mat:main.o mat.o
gcc -ansi -lm -Wall mat.o main.o -o mat
main.o:main.c mat.h def.h
gcc -ansi -pedantic -Wall -c main.c
mat.o:mat.c def.h
gcc -ansi -pedantic -Wall -c mat.c

Related

Error when trying to use Cygwin to compile a makefile in Clion

I am trying to compile a simple makefile program in C using Clion. I have the most up to date version of Clion and have reinstalled Cygwin and the suggested plugins as referenced by https://www.jetbrains.com/help/clion/quick-tutorial-on-configuring-clion-on-windows.html#Cygwin
However, I keep getting this error:
Error message
"CreateProcess error=2, The system cannot find the file specified
Cannot run program "make" (in directory "C:\College\Fall2020\COMS 327\coms327p1"): CreateProcess error=2, The system cannot find the file specified:
CreateProcess error=2, The system cannot find the file specified"
At first I figured it was just an issue with my make file, however I transferred this project over to linux and ran it from the command line and it works perfectly. So I am not sure why I cannot get this makefile project to run on windows.
For reference I am including my makefile as well:
all: gensine gendial
gensine: main.c
gcc -o gensine main.c -lm
gendial: main2.c
gcc -o gendial main2.c -lm
clean:
rm gensine gendial

Error building program using gcc plugin from linux kernel source tree

I am trying to use a grsecurity gcc plugin that I found on their unofficial linux kernel source tree (the respectre_plugin/ one).
My GCC version is 4.7, I modified scripts/gcc-plugins/Makefile to make it compile the plugin, and I built it with the root Makefile using make gcc-plugins, that shows no error.
Then, when I try to compile a C file that has a Spectre-like flaw, I got the following build error:
file.c:36:31: error: array_index_mask_nospec is not defined
This function is defined in respectre_plugin/respectre_plugin.c, and I have no idea why I've got this strange build error, if anyone knows about it...
My build invocation is the following:
gcc -Wall -Wextra -std=c99 -fplugin=/path/to/respectre_plugin.so -c file.c -o file.o
Thanks for any help !

Gaining sqlite3 functionality in C (Eclipse)

I would like to be able to use the sqlite3 functionality with C, I recently downloaded the sqlite3 amalgamation from the SQLite website and compiled this to get sqlite3.so and hence included this in my project. I have included what I believe to be the necessary libraries to compile the code however I always get the same error. The linker appears to be looking in the wrong folder for -lsqlite3 and I cant find this specified path anywhere in any of the project properties and it also does not appear to be a valid location on my PC!
Below is the output when I try to compile the code. If I am stupidly missing anything required for any help please let me know, bit of a beginner when using eclipse for C.
16:21:03 **** Build of configuration Debug for project SQLite ****
make all
Building file: ../main.c
Invoking: Cross GCC Compiler
arm-linux-gnueabihf-gcc -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"main.d" -MT"main.d" -o "main.o" "../main.c"
Finished building: ../main.c
Building target: SQLite
Invoking: Cross GCC Linker
arm-linux-gnueabihf-gcc -L/root/workspacecpp/SQLite/ -o "SQLite" ./main.o -lsqlite3.so
/home/development/raspberrypi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/../lib/gcc/arm-linux-gnueabihf/4.8.3/../../../../arm-linux-gnueabihf/bin/ld: cannot find -lsqlite3.so
collect2: error: ld returned 1 exit status
make: *** [SQLite] Error 1
You are cross-compiling, so you need to place the ARM[*] version of libsqlite3.so in a place where the cross compiler will look for it. This is likely somewhere in or below /home/development/raspberrypi/tools/arm-bcm2708/. See your cross-compiler's documentation.
[*] Of course you used your cross-compiler to create an ARM version of libsqlite3.so :-)

Eclipse IDE for C/C++, gcc can't find *.c document

I am working on a C project in Eclipse, the environment is windows X64,
When I tried to compile the program, it said:
11:54:29 **** Incremental Build of configuration Debug for project
TPCembarque **** Info: Internal Builder is used for build gcc
"-ID:\java workspace\TPCembarque\inc" "-ID:\java
workspace\TPCembarque\lib\" "-includeD:\java
workspace\TPCembarque\lib\libVirtualBoard.a" -O0 -g3 -Wall -c
-fmessage-length=0 -o "src\main.o" "..\src\main.c" gcc: error: workspace\TPCembarque\lib\libVirtualBoard.a -O0 -g3 -Wall -c
-fmessage-length=0 -o src\main.o ..\src\main.c : No such file or directory gcc: fatal error: no input files compilation terminated.
11:54:29 Build Finished (took 657ms)
so as a result it couldn't find main.c
All my data related to the project were saved in D:/systnum
and I created my project in D:/java workspace/TPCembarque.
I've already set the build environment as d:\systnum\MinGW\bin;d:\systnum\MSys\1.0\bin
I have already added the file main.c to the project 1
Could anybody tell me how to let the Compiler find main.c? thanks!
Is it possible to paste the makefile of your project?
I see a potential issue due to two different paths mentioned in your build log.
"src\main.o" -> src is a folder in current directory
"..\src\main.c" -> src is a folder in the directory one folder back.

x86_64-pc-cygwin gcc compilation error

Can someone help me to figure out this error.
I'm trying to compile a test program and it gives this error
/usr/lib/gcc/x86_64-pc-cygwin/4.8.3/../../../../x86_64-pc-cygwin/bin/ld: cannot find -ltest.
I gave correct path of lib cc test.c -I"./include" -L"./Lib" -ltest, still it is throwing error. Library is present in mentioned folder.
I tried too many things discussed over here but nothing helped me.
On Cygwin you should be able to build a library that generates the appropriate shared object with something like:
gcc -shared -o libtest.so -Wl,--out-implib,libtest.dll.a libtest.c
libtest.c would be the name of your .c file or a list of .c files used to build your library.
This should produce a libtest.dll.a and libtest.so . You use the import library to link your programs to the shared object. So you could compile your application with:
gcc test.c -I./include -LLib/ -ltest
The Lib/libtest.dll.a is a library (import library) that knows how to load the .so file at run-time.
To be more Windows like you could drop the .so suffix and use .dll. So compiling your shared object this way would work too:
gcc -shared -o libtest.dll -Wl,--out-implib,libtest.dll.a libtest.c
And then compile the client(test) as we did above:
gcc test.c -I./include -LLib/ -ltest
Because you compiled the shared object above with -o libtest.dll the import library that is created will now search for libtest.dll instead of libtest.so when your program is executed.
Please note that at run-time Windows searches your path for shared object (or dll). So you will have to move your shared object (or dll) to the directory you are running your application from; or copy your shared object (dll) to somewhere on your path; or add your ./Lib/ directory to your path.

Resources