I've looked all over the internet for this issue and doesnt appear to be a recurrent error.
The problem comes when I try to compile (I'm working on Ubuntu 12.04 distro) with g++ the main file that includes the lib, and it gets all the variables and functions except the MHD_RESPMEM_PERSISTENT variable on:
response = MHD_create_response_from_buffer(strlen(page), (void*)page, MHD_RESPMEM_PERSISTENT);
I already checked the linkers and everything to compile with -lmicrohttpd.
My Makefile looks like this:
CC = g++ -std=c++11
INCLUDE = -I. -I/opt/local/include
CFLAGS = -g -Wall $(INCLUDE)
#CFLAGS = -g -Wall $(INCLUDE) -coverage
LDFLAGS = -L/opt/local/lib -lmicrohttpd
all: $(TARGET)
$(OBJECTS): %.o: %.cc
$(CC) $(CFLAGS) -c $< -o $#
$(TARGET): $(OBJECTS)
$(CC) $(CFLAGS) -o $(TARGET) $(OBJECTS) $(LDFLAGS)
I didnt attach the linker fot $Objects, but its ok.
Actually, its very weird problem, because when i installed the packages (libmicrohttpd-dev and libmicrohttpd-dbg) on other PC's it worked out ok, but in some cases this issue comes up. The only solution that I came with was to re-install the OS again and start over, because everything was unefective.
It worked before on this very same computer, with the same OS, but since i had to format it, i have no idea to correct this issue.
Any ideas?.
MHD_RESPMEM_PERSISTENT as been added in libmicrohttpd 0.9.x, so version 0.4.6-1 is too old.
With Ubuntu, I don't know exactly how you can upgrade, but as libmicrohttpd as very few dependencies, maybe just add another ubuntu repo, or download a .deb and install it manually with dependencies.
Or apt-get remove the installed one, and manually install the latest version from gnu.org
Related
I need help configuring my makefile to use it with the GNU debugger. I am running it on debian.
I am quite new to makefiles and after going through similar questions I've tried adapting the answers of those to my code, but it didn't work out the ways I tried (probably because i don't fully understand the syntax of makefiles).
This is the original (shortened) makefile:
INC=-I include
all: libs poisson_solver
poisson_solver:
g++ -o bin/poisson $(INC) src/main.c\ src/problem_setup.c\ libs/timer_tools.o
libs: libs/timer_tools.o src/problem_setup.o
libs/timer_tools.o: utilities/gettime.c
g++ -c -o libs/timer_tools.o $(INC) utilities/gettime.c
src/problem_setup.o: src/problem_setup.c include/problem_setup.h
g++ -c -o src/problem_setup.o $(INC) src/problem_setup.c include/problem_setup.h
Your Makefile has several errors, and in general contains more cruft than it should.
Here is roughly what it should be:
CFLAGS = -Iinclude -g
OBJS = src/main.o src/problem_setup.o utilities/gettime.o
all: poisson_solver
poisson_solver: $(OBJS)
src/problem_setup.o: src/problem_setup.c include/problem_setup.h
See this section of the manual.
I'm using Google Test for C++ and trying to set it up on my linux machine.
My make file has the following code:
CC=g++
CFLAGS=-I $(GOOGLETESTDIR)/include -L $(GOOGLETESTDIR)/lib -lgtest -lpthread -Wall
DEPS=fib.h
OBJS=fib.o main.o
all: | r6
clean:
-rm -f r6 $(OBJS)
%.o: %.cpp $(DEPS)
$(CC) -c -o $# $< $(CFLAGS)
r6: $(OBJS)
$(CC) -o $# $^ $(CFLAGS)
.PHONY: all clean
I get the error when I run make:
/usr/bin/ld: cannot find -lgtest
How do I fix this? I'm new to this kind of testing and rather new to linux so I'm really lost.
I had this issue on Ubuntu 17.10 and basically what Alexander says is true.
Someone wrote a nice tutorial with explicit commands that can be found at https://www.eriksmistad.no/getting-started-with-google-test-on-ubuntu/
It boils down to:
sudo apt install libgtest-dev cmake
cd /usr/src/gtest
sudo cmake CMakeLists.txt
sudo make
sudo cp *.a /usr/lib
Personally, I would appreciate a solution that did not manually move files into /usr/lib, but on the plus side this works as-is.
As of now, Google test framework is not shipped with prebuilt binaries; you need to build them yourself. See full details on how to do that in README (for Debian, the path is /usr/src/googletest/googletest/README.md).
I'm working on a project and trying to compile my code. I just moved this code from windows (VC++) to linux and it worked fine on windows but I can't get it to compile on linux.
The program uses zeromq for TCP connections and I am getting multiple errors when I build. Errors of the type:
/usr/local/include/zmq.hpp:372: undefined reference to `zmq_bind'
/usr/local/include/zmq.hpp:415: undefined reference to `zmq_msg_send'
I've installed zeromq via its tarball on my linux machine, and manually added zmq.hpp to the /usr/local/include folder. I suspect that I am doing something wrong in my makefile and thats why I am getting these errors.
I am somewhat weak in creating makefiles so I would greatly appreciate if someone can take a look for me and tell me if there is an obvious issue with my makefile that is causing these issues. Here is my makefile
C = g++
DEBUG = -g
CFLAGS = -g -Wall -std=c++11
LFLAGS = -L/usr/local/lib/
INCLUDES = -I/usr/local/
LIBS = -libzmq.la
SRCS = main.cpp NetworkTestServer.cpp
OBJS = $(SRCS:.cpp=.o)
EXECUTABLE = tester
all: $(SRCS) $(EXECUTABLE)
$(EXECUTABLE): $(OBJS)
$(CC) $(EXECUTABLE) -o $(EXECUTABLE) $(LIBS)
.cpp.o:
$(CC) $(CFLAGS) $< -o $#
clean:
$(RM) *.o *~ $(EXECUTABLE)
Thanks much
Looks to me like your LIBS definition is wrong.
Typically, the lib part is omitted, along with the extension. So, try something like:
LIBS = -lzmq
If that doesn't work, ensure that this library is contained in the location as specified by your LFLAGS variable.
I am working on a C++ project and I need to use libtcl.
I am running Ubuntu 12.10 32bits and there is a problem when I try to compile my files :
g++ -o executable executable.o -L/usr/share/tcltk -lncurses -ltcl
/usr/bin/ld: cannot find -ltcl
libncurses is found but not libtcl...
Do you have any idea?
I have seen that libtcl8.4.so.0 libtcl8.5.so.0 exist in /usr/lib
The makefile that I am using looks like this :
CC = g++
CFLAGS = -g
LDFLAGS =
EXEC = executable
LIB = -L/usr/share/tcltk -lncurses -ltcl
all: executable
executable: executable.o
$(CC) $(LDFLAGS) -o $(EXEC) executable.o $(LIB)
executable.o: executable.cpp
$(CC) $(CFLAGS) -c executable.cpp
clean:
rm -f executable executable.o
Thanks
(Answered in a comment. See Question with no answers, but issue solved in the comments (or extended in chat) )
#soon wrote:
just create symlink to the your library like so #ln -s /usr/lib/libtcl8.5.so.0 /usr/lib/libtcl.so
I am trying to compile my program with debugging symbols for use in gdb. I have added the -g flag to my makefile but I still get "Reading symbols from ...(no debugging symbols found)" when I load the program in gdb. What is wrong??
Here is a stripped down example of my makefile which should have the relevant bits:
CPP = g++
CFLAGS = -c -g -Wall
$(BIN): $(OBJ)
$(CPP) $(LDFLAGS) $(OBJ) -o $(BIN) $(LIBS)
<test.o>: <test.cpp>
$(CPP) $(CFLAGS) <test.cpp> -o <test.o>
If you'd like to see the whole thing you can go here instead, though I don't think it's necessary:
http://pastebin.com/vGNjy0ga
Miscellaneous notes.. I'm compiling with MinGW on Windows and I have SFML and OpenGL as dependencies.
And no, the -s flag is nowhere to be found in my makefile.
Ahh. I'm very sorry. It turns out the "clean:" portion of my makefile is broken. Thus when I used make clean nothing happened. Deleting the .o files manually fixed the problem. The flags work perfectly now. Thanks to everyone who posted anyway! This can be deleted now.
I had the same issue when using a makefile I inherited on some old F77 code. I tried all the flags people recommend (-g -ggdb ...etc.)
the solution was run make clean
If you don't have that or know what it means, basically delete all the compiled (.o) files.
the makefile didn't know to recompile since only flags were changed, so I wasn't actually compiling with -g or -ggdb when I thought it was. Hope this helps someone!
try to replace
$(BIN): $(OBJ)
$(CPP) $(LDFLAGS) $(OBJ) -o $(BIN) $(LIBS)
with
$(BIN): $(OBJ)
$(CPP) $(CFLAGS) -o $(BIN) $(OBJ) $(LDFLAGS) $(LIBS)
(edit)
Note: -c option will not work with executable
I dont have much experience with Mingw but try replacing -g with -ggdb. This may solve your problem. According to gcc man page
Produce debugging information for use
by GDB. This means to use the most
expressive format available (DWARF 2,
stabs, or the native format if neither
of those are supported), including GDB
extensions if at all possible.
I think you need -g when linking the object into a binary code.
CPP = g++
CFLAGS = -g -Wall
$(BIN): $(OBJ)
$(CPP) $(CFLAGS) $(OBJ) -o $(BIN) $(LDFLAGS) $(LIBS)
<test.o>: <test.cpp>
$(CPP) $(CFLAGS) -c <test.cpp> -o <test.o>
I am not sure, but I think you need -g even while linking.