I am trying to use argon2 for C. I cloned the repo and tried to build it myself by typing make in the root directory of the repo. However, make threw this error:
Building without optimizations
cc -std=c89 -O3 -Wall -g -Iinclude -Isrc -pthread src/argon2.c src/core.c
src/blake2/blake2b.c src/thread.c src/encoding.c src/ref.c src/run.c -o argon2
process_begin: CreateProcess(NULL, cc -std=c89 -O3 -Wall -g -Iinclude -Isrc -
pthread src/argon2.c src/core.c src/blake2/blake2b.c src/thread.c
src/encoding.c src/ref.c src/run.c -o argon2, ...) failed.
make (e=2): The system cannot find the file specified.
make: *** [argon2] Error 2
I referred to this stack overflow post and I think I am getting this error because I do not have 'cc' installed. What is 'cc' and am I correct about 'cc' needing to be installed? I am on windows by the way. I know this is a super specific question but maybe someone can help me.
Related
I have reviewed the answer provided Here but I still cannot seem to make progress.
I am attempting to follow along with the online Stanford course CS107. I was able to complete assignments 2-3 but am stuck on assignment number 4.
I receive this error when I type "make" in the command line.
gcc -g -Wall -std=gnu99 -Wno-unused-function -c -o rss-news-search.o rss-news-search.c
gcc rss-news-search.o -g -Wall -std=gnu99 -Wno-unused-function -g -lnsl -lrssnews -L/home/pi/Desktop/C/StanfordHW/Assn4/assn-4-rss-news-search-lib/ -o rss-news-search
/usr/bin/ld: cannot find -lrssnews
collect2: error: ld returned 1 exit status
make: *** [Makefile:32: rss-news-search] Error 1
Here is the snippet of my Makefile:
CFLAGS = -g -Wall -std=gnu99 -Wno-unused-function $(DFLAG)
LDFLAGS = -g $(SOCKETLIB) -lnsl -lrssnews -L/home/pi/Desktop
/C/StanfordHW/Assn4/assn-4-rss-news-search-lib/$(OSTYPE)
PFLAGS= -linker=/usr/pubsw/bin/ld -best-effort
So, I tried doing what the previous answer suggested by moving the file "librssnews.a" to the folder /lib from where I am executing the make command. But this did not work.
Here is an image of my directory
Is there something else that I can try? Please excuse any obvious mistakes, as I'm still learning. Thank you.
I have a project with a makefile, linker file and some other c files. Whenever i try to run the make command from my windows. i end up with this error. I am using a cygwin terminal. The project was initially used Linux environment.
process_begin: CreateProcess(NULL, arm-none-eabi-gcc -c -g -Os -I. -fno-common -
ffunction-sections -ffreestanding -fno-builtin -mthumb -mcpu=cortex-m7 -specs=na
no.specs -Wall -Winline -fstack-usage -DSTM32F769xx -mfloat-abi=hard -mfpu=fpv5-
d16 -fno-strict-aliasing -Wno-discarded-qualifiers stm32init.c -o stm32init.o, .
..) failed.
make (e=2): The system cannot find the file specified.
make: *** [makefile:20: stm32init.o] Error 2
Let me know how i can fix this problem.
I am trying to study cs50 on linux , I downloaded everything I found on github, but now I can not compile my first program with make, but I can use clang instead clang hello.c -lcs50 -o hello which works just fine, but when I try to compile with make hello I get
:~/cs50/pset1# make hello
cc hello.c -o hello
/usr/bin/ld: /tmp/cczILfhu.o: in function 'main':
hello.c:(.text+0x1a): undefined reference to 'get_string'
collect2: error: ld returned 1 exit status
make: *** [<builtin>: hello] Error 1
I even moved the libcs50 folder that I downloaded to /usr/include/
but I still get the same results.
after I compile with clang , and then excute make hello it says
make: 'hello' is up to date.
I know it sounds dump but I am still newbie and looking for help.
thanks in advance.
For linking in the cs50 library (which you should have installed from https://github.com/cs50/libcs50 according to the instructions there), your linking command should specify the -lcs50 argument.
make usually needs a Makefile to control the build. In its absence it can use some implicit rules to guess the build process, like that hello.o could be built from hello.c and hello could be linked from hello.o and so forth, but it certainly cannot guess that libcs50 should be linked in.
Fortunately, the implicit linking rules include the contents of the variable LDLIBS in the correct, so you can fix this by writing a simple Makefile in the same directory, containing just
LDLIBS += -lcs50
I.e. "append the string -lcs50 to the current value of LDLIBS".
After that make hello will use the implicit rules and the new value of LDLIBS to execute
cc hello.c -lcs50 -o hello
Also do note that the cc command usually is GCC, not Clang, not that it should matter in CS50. It can be configured with the CC variable in Makefile:
CC := clang
Finally, it does make sense to enable warnings and pedantry in the compilation flags, for example:
CFLAGS += -Wall -Wextra -Werror -pedantic -std=c11
With all these 3 present, make hello will actually execute
clang -Wall -Wextra -Werror -pedantic -std=c11 hello.c -lcs50 -o hello
which means we did save quite a lot typing and get more useful diagnostics!
Of course for a more complicated build process you'd need to write a more complicated Makefile with dependency rules - say if your helloworld program consisted of hello.c and world.c linked together you could get by the implicit rules and just state that helloworld depends on both hello.o and world.o and should be linked together from these:
helloworld: hello.o world.o
$(CC) $(LDFLAGS) $^ $(LOADLIBES) $(LDLIBS)
# the command *must* be indented by a *single* tab character, not spaces!
# unfortunately SO editor does not make it easy to write tabs.
Just make new Makefile in the dir where is your *.c file:
$ touch Makefile
Then just add this strings to your Makefile:
CC=clang
CFLAGS=-fsanitize=signed-integer-overflow -fsanitize=undefined -ggdb3 -O0 -std=c11 -Wall -Werror -Wextra -Wno-sign-compare -Wno-unused-parameter -Wno-unused-variable -Wshadow
LDLIBS=-lcrypt -lcs50 -lm
Than you can compile *.c file just typing:
$ make hello.c
As part of my university studies I learn C programming. I'm using Eclipse Juno IDE.
Here is the problem: I have few .c and .h files, and a makefile made by our course staff. I want to build the project with this makefile. I spent hours searching all over the internet how to build and debug it, but everytime I think I got it an error jumps.
Can someone please explain once and for always how to do this process - build the project with the given makefile, and run it in debug mode so I can debug it?
It is important to mention that sometimes I failed to build the project and got the following message:
C:/TDM-GCC-64/bin/../lib/gcc/x86_64-w64-mingw32/5.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot open output file Assignment2altVersion.exe: Permission denied
However, I managed to build the project several times, but when I tried to run it in debug mode it was stuck either on "Launching: Configuring GDB" or "Launching C/C++ Application".
EDIT:
there are 6 files: SP_Stack.c, SP_Stack.h, SP_Aux.c, SP_Aux., SP_Stack_UnitTest.c, main.c
SP_Aux.c and main.c #include SP_Aux.h.
SP_Stack.c, SP_Aux. and SP_Stack_UnitTest.c #include SP_Stack.h
here's the makefile:
ex2: main.o SP_Aux.o SP_Stack.o
gcc -std=c99 -Wall -Werror -pedantic-errors main.o SP_Aux.o SP_Stack.o -o ex2
Stack_UnitTest: SP_Stack.o SP_Stack_UnitTest.o
gcc -std=c99 -Wall -Werror -pedantic-errors SP_Stack.o SP_Stack_UnitTest.o -o Stack_UnitTest
main.o: main.c SP_Aux.h SP_Stack.h
gcc -std=c99 -Wall -Werror -pedantic-errors -c main.c
SP_Stack.o: SP_Stack.c SP_Stack.h
gcc -std=c99 -Wall -Werror -pedantic-errors -c SP_Stack.c
SP_Stack_UnitTest.o: SP_Stack.h SP_Stack_UnitTest.c
gcc -std=c99 -Wall -Werror -pedantic-errors -c SP_Stack_UnitTest.c
SP_Aux.o: SP_Aux.c SP_Aux.h
gcc -std=c99 -Wall -Werror -pedantic-errors -c SP_Aux.c
clean:
rm -f main.o SP_Aux.o SP_Stack.o SP_Stack_UnitTest.o Stack_UnitTest ex2
the 6 files I mentioned and the makefile are all in the same directory.
I just tried it all over again: went to the right side of the screen to the "make targets" tab. I chose my project and created a target named "makefile" with "make" as build command. then I double clicked it and the project finishe building. when I tried to run it in debug mode it gets stuck on 96% with a message: "Launching: configuring GDB"
Trying to install a gem, but it can't find the headers, despite specifying them:
sudo gem install nokogiri -- --with-xml2-lib=/usr/local/lib --with-xml2-include=/usr/local/include/libxml2 --with-xml2-include=/usr/local/include/libxml2 --with-xslt-include=/usr/local/include/libxslt
Building native extensions. This could take a while...
ERROR: Error installing nokogiri:
ERROR: Failed to build gem native extension.
/usr/bin/ruby extconf.rb --with-xml2-lib=/usr/local/lib --with-xml2-include=/usr/local/include/libxml2 --with-xml2-include=/usr/local/include/libxml2 --with-xslt-include=/usr/local/include/libxslt
checking for #include <libxml/parser.h>
... no
-----
libxml2 is missing. please visit http://nokogiri.org/tutorials/installing_nokogiri.html for help with installing dependencies.
The /usr/local/include/libxml2/libxml/parser.h file does exist, so I don't see why this isn't working.
EDIT: I'm on Centos 5.4
If you dig into /usr/lib/ruby/1.8/mkmf.rb you can figure out how to simulate the check that's happening during install. In my case I could do this by creating a file called conftest.c containing:
#include <libxml/parser.h>
Then try running the command that gets passed into the try_do function. In my case this was:
gcc -E -I. -I/usr/lib64/ruby/1.8/x86_64-linux -I. -I-I-I/opt/local/include -I-I-I/usr/local/include -I-I-I/usr/include -I-I-I/usr/include -I-I-I/usr/include/libxml2 -I/opt/local/include/libxml2 -I/usr/local/include/libxml2 -I-I/opt/local/include -I-I/usr/local/include -I-I/usr/include -I-I/usr/include -I-I/usr/include/libxml2 -I/opt/local/include -I/usr/local/include -I/usr/include -I/usr/include -I/usr/include/libxml2 -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -fno-strict-aliasing -fPIC -g -DXP_UNIX -O3 -Wall -Wcast-qual -Wwrite-strings -Wconversion -Wmissing-noreturn -Winline conftest.c -o conftest.i
In my case I was missing gcc, which is probably not what you're hitting since you said you compiled from source. But hopefully if you run this command it should give you an idea of why you can't load in libxml2.
If you're interested in pre-built apparently EPEL has a rubygems-nokogiri package. Good chance I'll go this route in the end.