English 中文(简体)
汇编C++方案
原标题:Makefile issue with compiling a C++ program

我最近汇编了MySQL,并在Cygwin上工作,并从网上获得一个简单的测试例子,以核实它的工作。 测试实例汇编并成功。

然而,在将我的SQL纳入一个 mine矿项目时,我认为,由于Maksfile是如何设置的,因此,我没有在Makfiles和读物之后的经验,我有了更好的了解,但是仍然能够正确开展工作。

在我尝试和汇编我的霍比项目时,我发现了以下错误:

Obj/Database.o:Database.cpp:(.text+0x492): undefined reference to `_mysql_insert_id 
Obj/Database.o:Database.cpp:(.text+0x4c1): undefined reference to `_mysql_affected_rows 
collect2: ld returned 1 exit status
make[1]: *** [build] Error 1
make: *** [all] Error 2

我在这里是马克思,在我试图将我的SQL支持纳入该项目之前,它致力于汇编和建设来文方。 “LBMYSQL”的道路是正确的,由我的sql_config核实。

COMPILER = g++
WARNING1 = -Wall -Werror -Wformat-security -Winline -Wshadow -Wpointer-arith
WARNING2 = -Wcast-align -Wcast-qual -Wredundant-decls 
LIBMYSQL = -I/usr/local/include/mysql -L/usr/local/lib/mysql -lmysqlclient
DEBUGGER = -g3
OPTIMISE = -O

C_FLAGS =  $(OPTIMISE) $(DEBUGGER) $(WARNING1) $(WARNING2) -export-dynamic $(LIBMYSQL)
L_FLAGS = -lz -lm -lpthread -lcrypt $(LIBMYSQL)

OBJ_DIR = Obj/
SRC_DIR = Source/
MUD_EXE = project
MUD_DIR = TestP/
LOG_DIR = $(MUD_DIR)Files/Logs/

ECHOCMD = echo -e
L_GREEN = e[1;32m
L_WHITE = e[1;37m
L_BLUE  = e[1;34m
L_RED   = e[1;31m
L_NRM   = e[0;00m

DATE    = `date +%d-%m-%Y`
FILES   = $(wildcard $(SRC_DIR)*.cpp)
C_FILES = $(sort $(FILES))
O_FILES = $(patsubst $(SRC_DIR)%.cpp, $(OBJ_DIR)%.o, $(C_FILES))

all:
     @$(ECHOCMD) "  Compiling $(L_RED)$(MUD_EXE)$(L_NRM).";
     @$(MAKE) -s build

build: $(O_FILES)
     @rm -f $(MUD_EXE)
     $(COMPILER) -o $(MUD_EXE) $(L_FLAGS) $(O_FILES)
     @echo "  Finished Compiling $(MUD_EXE).";
     @chmod g+w $(MUD_EXE)
     @chmod a+x $(MUD_EXE)
     @chmod g+w $(O_FILES)

$(OBJ_DIR)%.o: $(SRC_DIR)%.cpp
     @echo "  Compiling $@";
     $(COMPILER) -c $(C_FLAGS) $< -o $@

.cpp.o:
     $(COMPILER) -c $(C_FLAGS) $<

clean:
     @echo "  Complete compile on $(MUD_EXE).";
     @rm -f $(OBJ_DIR)*.o $(MUD_EXE)
     @$(MAKE) -s build

我与马克茨案的功能一样,不但没有列举所有论点等等,反而 sp开了“拼凑[名称]”等。

如果我补充说——c 在L_FLAGS中,它会汇编(我想)但会发现:

g++: Obj/Database.o: linker input file unused because linking not done

在整整整一天的尝试和研究之后,我不敢解决我的问题,因此,我来到大家,看看你能否向我解释为什么会发生这一切,如果可能的话,会采取步骤解决。

Regards, Steve

最佳回答

变化

$(COMPILER) -o $(MUD_EXE) $(L_FLAGS) $(O_FILES)

纽约总部

$(COMPILER) -o $(MUD_EXE) $(O_FILES) $(L_FLAGS)

联系人搜索和处理图书馆和物体档案,按其具体要求进行。 因此,当你在物体档案上提到图书馆时,物体档案中使用的功能可能不会从图书馆中装载。

问题回答

您是否尝试分别使用<代码>mysql_config_cflags和mysql_config_libs?





相关问题
Undefined reference

I m getting this linker error. I know a way around it, but it s bugging me because another part of the project s linking fine and it s designed almost identically. First, I have namespace LCD. Then I ...

C++ Equivalent of Tidy

Is there an equivalent to tidy for HTML code for C++? I have searched on the internet, but I find nothing but C++ wrappers for tidy, etc... I think the keyword tidy is what has me hung up. I am ...

Template Classes in C++ ... a required skill set?

I m new to C++ and am wondering how much time I should invest in learning how to implement template classes. Are they widely used in industry, or is this something I should move through quickly?

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

typedef ing STL wstring

Why is it when i do the following i get errors when relating to with wchar_t? namespace Foo { typedef std::wstring String; } Now i declare all my strings as Foo::String through out the program, ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

Window iconification status via Xlib

Is it possible to check with the means of pure X11/Xlib only whether the given window is iconified/minimized, and, if it is, how?

热门标签