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 7813787
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T04:59:00+00:00 2026-06-02T04:59:00+00:00

I am getting undefined reference to ‘mysql_suchandsuch@#’ messages when trying to link my program

  • 0

I am getting undefined reference to 'mysql_suchandsuch@#' messages when trying to link my program with the MySQL libraries supplied with the 5.5 server. When MySQL was installed, I used the default path, which for me on Windows is C:\Program Files\MySQL\MySQL Server 5.5\. Originally, I had thought that the spaces are causing my grief, but I think I’ve correctly worked out how to point to the library path without spaces (still with no luck). If there’s another probable cause, please let me know.

I have reviewed a series of questions on this site trying to resolve my issue…

  • Question 1
  • Question 2
  • Question 3
  • Question 4
  • Question 5
  • Question 6
  • Question 7

Using mingw/g++, I have tried to link using the following options, based on my own research as well as suggestions here:

  • -L”C:\Program Files\MySQL\MySQL Server 5.5\lib\” -llibmysql.lib
  • -L”C:\Program Files\MySQL\MySQL Server 5.5\lib\” -lmysqlclient.lib
  • -L”C:\Progra~1\MySQL\MySQLS~1.5\lib\” -llibmysql.lib
  • -LC:\Progra~1\MySQL\MySQLS~1.5\lib\ -lmysqlclient.lib
  • -L”C:\Progra~1\MySQL\MySQLS~1.5\lib\” -lmysql

In all cases, I have put the -L/-l options at the right-most part of the statement, as I understand this can matter.

I have confirmed the libraries do exist. In the /lib dir, I have libmysql.lib, mysqlclient.lib, and libmysql.dll. I have not tried to link with the .dll, as no tutorial/forum I’ve reviewed suggested that.

I am not using MAKEFILES.

Does anyone have specific experience with g++/MySQL?

  • 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-06-02T04:59:00+00:00Added an answer on June 2, 2026 at 4:59 am

    The following commands work fine for me using a GCC 4.6.1 from November 2011:

    g++ my.cpp -I D:\Opt\MySQL5.5\include ^
      D:\Opt\MySQL5.5\lib\libmysql.dll -o myWithDll.exe
    
    g++ my.cpp -I D:\Opt\MySQL5.5\include ^
      -L D:\Opt\MySQL5.5\lib -lmysql -o myWithLib.exe
    

    So both linking against the LIB and the DLL do work.

    You may get a warning (see Gaffi’s comment). This is because the linker does fuzzy linking for you without you having it specified; normally, it would have failed to link. It is being nice, though, and making it work for you, at the same time warning you about things happening without your having requested them. The way to suppress the warning is to make fuzzy linking explicit:

    g++ -Wl,--enable-stdcall-fixup my.cpp -I D:\Opt\MySQL5.5\include ^
      D:\Opt\MySQL5.5\lib\libmysql.dll -o myWithDll.exe
    
    g++ -Wl,--enable-stdcall-fixup my.cpp -I D:\Opt\MySQL5.5\include ^
      -L D:\Opt\MySQL5.5\lib -lmysql -o myWithLib.exe
    

    This is a Cygwin/RedHat/MinGW extension to the linker; the docs are here:

    --enable-stdcall-fixup
    --disable-stdcall-fixup
    

    If the link[er] finds a symbol that it cannot resolve, it will attempt to
    do “fuzzy linking” by looking for another defined symbol that differs
    only in the format of the symbol name (cdecl vs stdcall) and will
    resolve that symbol by linking to the match. For example, the
    undefined symbol _foo might be linked to the function _foo@12, or the
    undefined symbol _bar@16 might be linked to the function _bar. When
    the linker does this, it prints a warning, since it normally should
    have failed to link, but sometimes import libraries generated from
    third-party dlls may need this feature to be usable. If you specify
    –enable-stdcall-fixup, this feature is fully enabled and warnings
    are not printed. If you specify –disable-stdcall-fixup, this feature is
    disabled and such mismatches are considered to be errors. [This option
    is specific to the i386 PE targeted port of the linker]

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

Sidebar

Related Questions

I'm getting a Can't use an undefined value as a HASH reference error trying
When building my C++ program, I'm getting the error message undefined reference to 'vtable...
Why am I getting an undefined reference error using gcc? I am trying to
I am trying to link several object files and I am getting 3 undefined
I am getting an undefined reference when trying to use variables from my namespace.
I am getting a linking error (undefined reference) when I try to link my
I'm getting undefined reference when I build an application in Windows witn mingw32 (it
Here is the code, why am I getting an undefined reference while linking? g++
I'm getting an Undefined reference error message, on this statement: GlobalClass *GlobalClass::s_instance = 0;
I'm getting error undefined reference to `pthread_attr_init', even though that should be in pthread.h.

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.