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

  • Home
  • SEARCH
  • 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 8638745
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T10:48:56+00:00 2026-06-12T10:48:56+00:00

I am to compile a multi-file C++ program, and have the following error; Undefined

  • 0

I am to compile a multi-file C++ program, and have the following error;

Undefined symbols for architecture i386:
  "included::printMSG()", referenced from:
      _main in ccQwMj1l.o
ld: symbol(s) not[Finished in 0.3s with exit code 1] found for architecture i386
collect2: ld returned 1 exit status

My code:
main.cpp: https://gist.github.com/3845822

included.cpp: https://gist.github.com/3845825

included.h: https://gist.github.com/3845827

(confirmed to work with g++)

EDIT: I am not putting these files in a project, they are just all in the same folder, and I’m compiling main.cpp

  • 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-12T10:48:57+00:00Added an answer on June 12, 2026 at 10:48 am

    You can’t just compile a single file and hope all other files are automatically linked to it to create the final program.

    One way to make that happen is to use a program called make, which reads a Makefile that has rules that make follows`.

    A simple Makefile can look like this:

    CXXFLAGS = -Wall -g
    
    my_pogram: main.o other_file.o third_file.o
        g++ main.o other_file.o third_file.o -o my_program
    
    main.o: main.cpp
        g++ $(CXXFLAGS) -c -o main.o main.cpp
    
    other_file.o: other_file.cpp
        g++ $(CXXFLAGS) -c -o other_file.o other_file.cpp
    
    third_file.o: third_file.cpp
        g++ $(CXXFLAGS) -c -o third_file.o third_file.cpp
    

    There are other similar programs to handle this. One that is popular is CMake.

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

Sidebar

Related Questions

I have a multi-module project. I thought I can compile only a single module
I compile my C++ program to LLVM IR using the following command. clang++ -O4
I have a multi threaded program in C that was working well but was
I've been trying to compile a multi-file project, but every time I try to
related to (gcc) Multi-Dim Array or Double Pointer for Warning-free Compile , is there
GCC is a very well respected multi-language compiler (from what I've gathered). One thing
I compile my file with javac myfile.java But when I run myfile.class file with
I am trying to compile 2 shared libraries in the same mk file. The
I have tried to use clang 3.0 with libc++ and C++0x. I have compile
I am making a multi-lingual (computer languages) notepad in WinForms. I have a menu

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.