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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T04:27:50+00:00 2026-06-04T04:27:50+00:00

The following make output is showing an undefined reference, and I am not sure

  • 0

The following make output is showing an undefined reference, and I am not sure what is causing it. Could someone help?

"/usr/bin/make" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
make[1]: Entering directory `/cygdrive/g/workspace/c_cpp/MongoDriverTest'
"/usr/bin/make"  -f nbproject/Makefile-Debug.mk dist/Debug/Cygwin_4.x-Windows/mongodrivertest.exe
make[2]: Entering directory `/cygdrive/g/workspace/c_cpp/MongoDriverTest'
mkdir -p build/Debug/Cygwin_4.x-Windows
rm -f build/Debug/Cygwin_4.x-Windows/main.o.d
gcc -std=c99   -c -g -I../mongodb-mongo-c-driver/src/\*.c -MMD -MP -MF build/Debug/Cygwin_4.x-Windows/main.o.d -o build/Debug/Cygwin_4.x-Windows/main.o main.c
mkdir -p dist/Debug/Cygwin_4.x-Windows
gcc -std=c99    -o dist/Debug/Cygwin_4.x-Windows/mongodrivertest build/Debug/Cygwin_4.x-Windows/main.o  
nbproject/Makefile-Debug.mk:61: recipe for target `dist/Debug/Cygwin_4.x-Windows/mongodrivertest.exe' failed
make[2]: Leaving directory `/cygdrive/g/workspace/c_cpp/MongoDriverTest'
nbproject/Makefile-Debug.mk:58: recipe for target `.build-conf' failed
make[1]: Leaving directory `/cygdrive/g/workspace/c_cpp/MongoDriverTest'
nbproject/Makefile-impl.mk:39: recipe for target `.build-impl' failed
build/Debug/Cygwin_4.x-Windows/main.o: In function `main':
/cygdrive/g/workspace/c_cpp/MongoDriverTest/main.c:19: undefined reference to `_mongo_connect'
collect2: ld returned 1 exit status
make[2]: *** [dist/Debug/Cygwin_4.x-Windows/mongodrivertest.exe] Error 1
make[1]: *** [.build-conf] Error 2
make: *** [.build-impl] Error 2

And this is the content of my main.c:

#include <stdio.h>
#include <stdlib.h>
#include "../mongodb-mongo-c-driver/src/mongo.h"

int main(int argc, char** argv) {
    int status;
    mongo conn[1];

    status=mongo_connect(conn, "127.0.0.1", 27017);
    return EXIT_SUCCESS;
}  

It was working two days ago, I reinstalled the OS and now it’s not working anymore and I don’t seem to find the cause. mongo.h exists, mongo.o is there as well. mongo_connect is in mongo.c. Any idea?

  • 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-04T04:27:50+00:00Added an answer on June 4, 2026 at 4:27 am

    Your link line is:

    gcc -std=c99 -o dist/Debug/Cygwin_4.x-Windows/mongodrivertest build/Debug/Cygwin_4.x-Windows/main.o  
    

    It doesn’t tell GCC where to collect mongo_connect() from. You need to specify the Mongo library on the command line.

    Given the include line in your source code:

    #include "../mongodb-mongo-c-driver/src/mongo.h"
    

    You might add options:

    -L../mongodb-mongo-c-driver/lib -lmongo
    

    to the link line. Both the location and the library name are guesses. That would pick up libmongo.dll or libmongo.lib from the specified directory.

    If you can’t find the library under the ../mongodb-mongo-c-driver directory, somewhere, you may have to build and install it. Alternatively, it may already be installed and you simply need to ensure you are referencing the correct locations where it is installed.


    Also, as a general rule, avoid pathnames like that in the source code. You should specify:

    #include "mongo.h"
    

    and supply a compile line option to specify where to look for it:

    -I../mongodb-mongo-c-driver/src
    

    See also: What are the benefits of a relative path such as #include "../include/header.h" for a header?.

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

Sidebar

Related Questions

Can someone tell me how I can make the following output? I have a
I am running the following command: make -f makefile.gcc And the output is: make:
For the following make file copied below, I am getting the missing separator error.
I use functions like the following to make temporary tables out of crosstabs queries.
i have two strings in a php i want to make following checks in
I make the following call to the DB. @patientRegistration = PatientRegistration.find(:all, :conditions=>[name = '#{patientName}'])
How to make the following table into a JSON string in jquery/javascript? <table> <thead>
How to make the following method more functional-linq-style? public static Dictionary<T, T> MergeDict<T, T>(Dictionary<T,
How do I make the following url forbidden in apache; main/index.php?site=ing I have tried
I am using the following code to make a HttpWebRequest and render the XML

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.