C development under NETBEANS, cc1 - c

I installed netbeans to write code in C. But there is problem using Mingw compilers. It works just fine, till i try to run the project.
First it was unable to find cc1.exe while trying to run it. When i found it and manually copied into the same folder there is just another error.
"C:/bin/make.exe" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
C:\bin\make.exe[1]: Entering directory `D:/1/2/Skola/IZP/programovani/projekt4netbeans/CppApplication_6'
"C:/bin/make.exe" -f nbproject/Makefile-Debug.mk dist/Debug/MinGW_1-Windows/cppapplication_6.exe
C:\bin\make.exe[2]: Entering directory `D:/1/2/Skola/IZP/programovani/projekt4netbeans/CppApplication_6'
mkdir -p build/Debug/MinGW_1-Windows
rm -f build/Debug/MinGW_1-Windows/main.o.d
gcc.exe -c -g -MMD -MP -MF build/Debug/MinGW_1-Windows/main.o.d -o build/Debug/MinGW_1-Windows/main.o main.c
cc1: error: command line option '-lang-c' is valid for the driver but not for C
C:\bin\make.exe[2]: *** [build/Debug/MinGW_1-Windows/main.o] Error 1
C:\bin\make.exe[2]: Leaving directory `D:/1/2/Skola/IZP/programovani/projekt4netbeans/CppApplication_6'
C:\bin\make.exe[1]: *** [.build-conf] Error 2
C:\bin\make.exe[1]: Leaving directory `D:/1/2/Skola/IZP/programovani/projekt4netbeans/CppApplication_6'
C:\bin\make.exe: *** [.build-impl] Error 2
BUILD FAILED (exit value 2, total time: 2s)
if someone could help me with that.. thanks :)

Make shure you have current versions of Netbeans and MinGw and that you have a correct installation (Configuring the NetBeans IDE for C/C++/Fortran).
On mingw you should not use make from mingw/bin, but the one from msys (<mingw>/msys/1.0/bin/make.exe)

Related

Why Terminal told me this "No rule to make target 'xxx.o', needed by 'xxx.mod'. Stop" when I run 'make' on Ubuntu18.04LTS?

I'm trying to cross compile a drive for xilinx ZynqMPsoc's ARM Cortex A53 cpu on Ubuntu 18.04LTS, My Linux version is 5.4.0-131-generic (buildd#lcy02-amd64-092) , gcc version is 7.5.0 (Ubuntu 7.5.0-3ubuntu1~18.04)
The workspace folder contains 2 files: chrdevbase.c, Makefile. The details of Makefile are shown below:
`
KERN_DIR := /home/edaos/programfiles/linuxkernel-xlnx-xilinx-v2022.1/linux-xlnx-xilinx-v2022.1
obj-m := chrdevbase.o
all:
make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- -C $(KERN_DIR) M=$(PWD) modules
clean:
make -C $(KERN_DIR) M=$(PWD) clean
`
When I entered 'make' in terminal, it told me:
`
warning: the compiler differs from the one used to build the kernel
The kernel was built by: gcc (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0
You are using: aarch64-xilinx-linux-gcc.real (GCC) 11.2.0
make[2]: *** No rule to make target '/home/edaos/programfiles/linuxkernel-xlnx-xilinx-v2022.1/linux-xlnx-xilinx-v2022.1/drivers/1_chrdevbase/chrdevbase.o', needed by '/home/edaos/programfiles/linuxkernel-xlnx-xilinx-v2022.1/linux-xlnx-xilinx-v2022.1/drivers/1_chrdevbase/chrdevbase.mod'. Stop.
Makefile:1868: recipe for target '/home/edaos/programfiles/linuxkernel-xlnx-xilinx-v2022.1/linux-xlnx-xilinx-v2022.1/drivers/1_chrdevbase' failed
make[1]: *** [/home/edaos/programfiles/linuxkernel-xlnx-xilinx-v2022.1/linux-xlnx-xilinx-v2022.1/drivers/1_chrdevbase] Error 2
`
Then I checked my workspace folder, it still contained 2 files: chrdevbase.c, Makefile.
So I wonder what is 'chrdevbase.mod' said in error? And what should I do to fix this bug?
Thank you very much for answering my question.
I tried to cross compile chrdevbase.c directly with aarch64-linux-gnu-gcc, the commands are as flows:
aarch64-linux-gnu-gcc -I /home/edaos/programfiles/linuxkernel-xlnx-xilinx-v2022.1/linux-xlnx-xilinx-v2022.1/include -l /home/edaos/programfiles/linuxkernel-xlnx-xilinx-v2022.1/linux-xlnx-xilinx-v2022.1/lib chrdevbase.c (/home/edaos/programfiles/linuxkernel-xlnx-xilinx-v2022.1/linux-xlnx-xlinx-v2022.1 is the folder where the linux's source code is stored )
Then the errors occurred again:
`
In file included from /home/edaos/programfiles/linuxkernel-xlnx-xilinx-v2022.1/linux-xlnx-xilinx-v2022.1/include/linux/kernel.h:8,
from chrdevbase.c:13:
/home/edaos/programfiles/linuxkernel-xlnx-xilinx-v2022.1/linux-xlnx-xilinx-v2022.1/include/linux/linkage.h:8:10: fatal error: asm/linkage.h: No such file or directory
8 | #include <asm/linkage.h>
| ^~~~~~~~~~~~~~~
compilation terminated.
`
I entered ($linux_source)/include, found that there is no folder named 'asm',but 'asm-generic'. At the same time, the folder '/usr/aarch64-linux-gnu/include' contained 'asm' and 'asm-generic'. Why is it so? What should I do to compile my drive file?

Compiling C using make in windows (MinGW)

I am following the book "Learn C the Hard Way" and I have reached the section where you compile the code using makefiles. I keep getting errors that the file was not found when running make clean.
Here is the error followed by the make file and the directory
C:\Users\Me\Desktop\C Code\HARD WAY\Dust off that compiler>make clean
rm -f main.c
process_begin: CreateProcess(NULL, rm -f main.c, ...) failed.
make (e=2): The system cannot find the file specified.
make: *** [makefile:7: clean] Error 2
EXECUTABLE=main.exe
CC="C:\Program Files\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64\bin\gcc.exe"
CFLAGS=-Wall -g
clean:
rm -f main
directories
EDIT: I removed the .c from the "rm -f main" as it seems to be a small error but has made no difference to the end result
EDIT 2: I worked out that the make file is issuing linux commands which is why it wasn't working, replacing rm with del fixes the issue
I worked out that the make file is issuing linux commands which is why it wasn't working, replacing rm with del and removing -f fixes the issue

netbeans c program build fail with tdm-gcc msys

i have recently started to use netbeans to program in c. i usually use codeblocks. i have installed tdm-gcc and msys for this purpose.
the programs are getting compiled successfully. but on execution, it shows build failed(exit value 2).
"/C/msys/1.0/bin/make.exe" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
make.exe[1]: Entering directory `/f/NetBeansProjects/C_Programs'
"/C/msys/1.0/bin/make.exe" -f nbproject/Makefile-Debug.mk dist/Debug/MinGW_TDM-Windows/c_programs.exe
make.exe[2]: Entering directory `/f/NetBeansProjects/C_Programs'
mkdir -p build/Debug/MinGW_TDM-Windows
rm -f "build/Debug/MinGW_TDM-Windows/main.o.d"
gcc -c -g -MMD -MP -MF "build/Debug/MinGW_TDM-Windows/main.o.d" -o build/Debug/MinGW_TDM-Windows/main.o main.c
mkdir -p dist/Debug/MinGW_TDM-Windows
gcc -o dist/Debug/MinGW_TDM-Windows/c_programs build/Debug/MinGW_TDM-Windows/main.o build/Debug/MinGW_TDM-Windows/structure_union.o
build/Debug/MinGW_TDM-Windows/structure_union.o: In function `main':
F:\NetBeansProjects\C_Programs/structure_union.c:32: multiple definition of `main'
build/Debug/MinGW_TDM-Windows/main.o:F:\NetBeansProjects\C_Programs/main.c:15: first defined here
collect2.exe: error: ld returned 1 exit status
make.exe[2]: *** [dist/Debug/MinGW_TDM-Windows/c_programs.exe] Error 1
make.exe[2]: Leaving directory `/f/NetBeansProjects/C_Programs'
make.exe[1]: *** [.build-conf] Error 2
make.exe[1]: Leaving directory `/f/NetBeansProjects/C_Programs'
make.exe": *** [.build-impl] Error 2
BUILD FAILED (exit value 2, total time: 657ms)
can somebody help me with what im doing wrong?
You have multiple main() functions in your project:
[…]/structure_union.c:32: multiple definition of `main'
It seems there's one in structure_union and another one in main.c (line 15).
C allows only one definition of main(); remove one of these and it should work.

error while building Glibc-2.11.1 for Linux From Scratch

I am trying to configure glibc-2.11.1 using gcc-4.6.1 for kernel 3.16. I am following steps given at http://www.gnu.org/software/libc/manual/html_node/Configuring-and-compiling.html when i am doing make after compiling some file it is giving
make -r PARALLELMFLAGS="" CVSOPTS="" -C ../glibc-2.11.1 objdir=`pwd` all
make[1]: Entering directory `/home/amar/Desktop/glib1/glibc-2.11.1'
make subdir=csu -C csu ..=../ subdir_lib
make[2]: Entering directory `/home/amar/Desktop/glib1/glibc-2.11.1/csu'
gcc /home/amar/Desktop/glib1/gnu/csu/crti.S -c -I../include -I/home/amar/Desktop/glib1/gnu/csu -I/home/amar/Desktop/glib1/gnu -I../sysdeps/i386/elf -I../nptl/sysdeps/unix/sysv/linux/i386/i686 -I../sysdeps/unix/sysv/linux/i386/i686 -I../nptl/sysdeps/unix/sysv/linux/i386 -I../sysdeps/unix/sysv/linux/i386 -I../nptl/sysdeps/unix/sysv/linux -I../nptl/sysdeps/pthread -I../sysdeps/pthread -I../sysdeps/unix/sysv/linux -I../sysdeps/gnu -I../sysdeps/unix/common -I../sysdeps/unix/mman -I../sysdeps/unix/inet -I../sysdeps/unix/sysv/i386 -I../nptl/sysdeps/unix/sysv -I../sysdeps/unix/sysv -I../sysdeps/unix/i386 -I../nptl/sysdeps/unix -I../sysdeps/unix -I../sysdeps/posix -I../sysdeps/i386/i686/fpu -I../nptl/sysdeps/i386/i686 -I../sysdeps/i386/i686 -I../sysdeps/i386/i486 -I../nptl/sysdeps/i386/i486 -I../sysdeps/i386/fpu -I../nptl/sysdeps/i386 -I../sysdeps/i386 -I../sysdeps/wordsize-32 -I../sysdeps/ieee754/ldbl-96 -I../sysdeps/ieee754/dbl-64 -I../sysdeps/ieee754/flt-32 -I../sysdeps/ieee754 -I../sysdeps/generic/elf -I../sysdeps/generic -I../nptl -I.. -I../libio -I. -D_LIBC_REENTRANT -include ../include/libc-symbols.h -DHAVE_INITFINI -DASSEMBLER -I/home/amar/Desktop/glib1/gnu/csu/. -DGAS_SYNTAX -g -Wa,--noexecstack -g0 -o /home/amar/Desktop/glib1/gnu/csu/crti.o
/tmp/ccEB9vct.s: Assembler messages:
/tmp/ccEB9vct.s: Error: open CFI at the end of file; missing .cfi_endproc directive
/tmp/ccEB9vct.s: Error: open CFI at the end of file; missing .cfi_endproc directive
make[2]: *** [/home/amar/Desktop/glib1/gnu/csu/crti.o] Error 1
make[2]: Leaving directory `/home/amar/Desktop/glib1/glibc-2.11.1/csu'
make[1]: *** [csu/subdir_lib] Error 2
make[1]: Leaving directory `/home/amar/Desktop/glib1/glibc-2.11.1'
make: *** [all] Error 2
Why is it so ? How I can rectify this error? Please help me. Thanks in advance
Why is it so ?
The file crti.S that is failing to build is generated by compiling csu/initfini.c, and then splitting the resulting initfini.s on "magic markers".
Unfortunately, this splitting is extremely dependent on the version of gcc that is used to generate initfini.s, and doesn't always work.
This entire mechanism has been eliminated in Feb 2012.
Your options are:
build a newer version of glibc (current is 2.19), or
build using older version of GCC (Google search shows many instances of gcc-4.6 causing this problem).

Basic Cmake and make on Mac OS Maverick for C

I'm a complete beginner in using Cmake to compile my own C code and I'm running Mac OS X Mavericks.
My problem is as follow. For my intro to Cmake, created a folder containing the following folders
bin/
build/
src/
fonctions.h
fonctions.c
main.c
Here my CMakeLists.txt file:
project(Addition)
add_executable(
bin/addition
src/main.c
src/fonctions.h
src/fonctions.c
)
When I run:
$ cmake . -G "Unix Makefiles"
and then make from my root folder, no problem.
But when I run:
$ cmake .. -G "Unix Makefiles"
and then make from my /build folder I got this error message:
Linking C executable bin/addition
ld: can't open output file for writing: bin/addition, errno=2 for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [bin/addition] Error 1
make[1]: *** [CMakeFiles/bin/addition.dir/all] Error 2
make: *** [all] Error 2
Anyone knows why?
Remove bin/ from your add_executable and use CMAKE_RUNTIME_OUTPUT_DIRECTORY to change your build location
add_executable(
addition
src/main.c
src/fonctions.h
src/fonctions.c
)

Resources