Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 811879
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T01:06:49+00:00 2026-05-15T01:06:49+00:00

I recently got MySQL compiled and working on Cygwin, and got a simple test

  • 0

I recently got MySQL compiled and working on Cygwin, and got a simple test example from online to verify that it worked. The test example compiled and ran successfully.

However, when incorporating MySQL in a hobby project of mine it isn’t compiling which I believe is due to how the Makefile is setup, I have no experience with Makefiles and after reading tutorials about them, I have a better grasp but still can’t get it working correctly.

When I try and compile my hobby project I recieve errors such as:

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

Here is my Makefile, it worked with compiling and building the source before I attempted to put in MySQL support into the project. The LIBMYSQL paths are correct, verified by ‘mysql_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

I like the functionality of the Makefile, instead of spitting out all the arguments etc, it just spits out the “Compiling [Filename]” etc.

If I add -c to the L_FLAGS then it compiles (I think) but instead spits out stuff like:

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

After a full day of trying and research on google, I’m no closer to solving my problem, so I come to you guys to see if you can explain to me why all this is happening and if possible, steps to solve.

Regards,
Steve

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T01:06:50+00:00Added an answer on May 15, 2026 at 1:06 am

    Try changing

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

    to

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

    The linker searches and processes libraries and object files in the order they are specified. Thus when you mention the libraries before the object files, the functions used in the object files may not be loaded from the libraries.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I recently got a notification from a McAfee service (what used to be called
I recently got involved in a Java project at work: we're using MyEclipse for
I just recently got my first mac. I do lots of programming on windows
A colleague of mine recently got bitten badly by writing out of bounds to
I'm involved in building a donation form for non-profits. We recently got hit by
Recently we got a new server at the office purely for testing purposes. It
Recently I got IE7 crashed on Vista on jar loading (presumably) with the following
I got into a mini-argument with my boss recently regarding project failure. After three
I've got a book on python recently and it's got a chapter on Regex,
I've got build server running CruiseControl.NET and recently it started throwing this error on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.