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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T17:54:17+00:00 2026-05-28T17:54:17+00:00

How do you link 2 c library files, to a c++ file? Right now

  • 0

How do you link 2 c library files, to a c++ file?

Right now I am doing this:

> gcc -c file1.c (this works fine) 

> gcc -c file2.c ( this works fine)

> g++ -c myc++file.cpp (this works fine)

> g++ -o program myc++file.o file1.o file2.o

-> I get an error on this last one saying that their is a undefined reference to a function in myc++file.o, but that function is defined in file2.o. Something is wrong, but I just cant figure it out.

Any ideas?

  • 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-28T17:54:18+00:00Added an answer on May 28, 2026 at 5:54 pm

    Is this function static?

    Did you use extern "C" in myc++file.cpp?

    if the answers is no and yes, show us some code.

    (By the way, try to check using nm if that function is really in file2.o)

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

Sidebar

Related Questions

There's a #pragma command to link in a library from the source file rather
Is it possible for gcc to link against a library that was created with
I have created a static library following this link . But I am facing
http://msdn.microsoft.com/en-us/library/ms189797.aspx In this link they are committing a transaction within catch clause IF (XACT_STATE())
Have followed every step correctly from this link http://msdn.microsoft.com/en-us/library/ms746621.aspx When trying to localize the
I'm trying to compile this C++ program which utilizes the GLUT32 libraries. Right now
The problem below is ralated to my previous question Converting static link library to
Is it correct to link a static library (.lib) compiled with VS 2005 with
Is it possible to link a static library built with VS2005 into an application
I have a shared library that I wish to link an executable against using

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.