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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T12:12:33+00:00 2026-05-22T12:12:33+00:00

I downloaded a generic AVL implementation from: http://sourceforge.net/projects/standardavl/files/standardavl/0.1/ The makefile in this project compiles

  • 0

I downloaded a generic AVL implementation from:
http://sourceforge.net/projects/standardavl/files/standardavl/0.1/

The makefile in this project compiles correctly the code. The compiler produces the follow output:

g++ -pedantic -Wall -O3 -c standardavl.cpp -o standardavl.o
g++ -pedantic -Wall -O3 -c Point.cpp -o Point.o
g++ -o standardavl  standardavl.o Point.o
g++ -o genpoints genpoints.o Point.o

The makefile compiles only “standardavl.cpp”, because standartavl includes “AvlTree.h” and this file includes “AvlTree.cpp”:

standardavl.cpp

#include "AvlTree.h"
#include "Point.h"
(...)

AvlTree.h

(...)
#include "AvlTree.cpp"

In my project I removed the last line (#include “AvlTree.cpp”) from the file AvlTree.h and compiled individually that files. I do not use the file “standardavl.cpp” also. I changed the file Point.h to KeyPair.h and implemented all operators there.

My compiler produces the follow output:

g++ -pedantic -Wall -O3 -c -o ../lib/CPUTimer.o ../lib/CPUTimer.cpp -I. -I../lib 
g++ -pedantic -Wall -O3 -c -o ../lib/AvlTree.o ../lib/AvlTree.cpp -I. -I../lib 
g++ -pedantic -Wall -O3 -c -o ../lib/keypair.o ../lib/keypair.cpp -I. -I../lib 
g++ -pedantic -Wall -O3 -c -o graph.o graph.cpp -I. -I../lib 
g++ -pedantic -Wall -O3 -c -o dijkstra.o dijkstra.cpp -I. -I../lib 
g++ -pedantic -Wall -O3 -o ../../q1 ../lib/CPUTimer.o ../lib/AvlTree.o ../lib/keypair.o graph.o dijkstra.o questao1.cpp -I. -I../lib 
dijkstra.o: In function 'Dijkstra::executeAvl(int)':
dijkstra.cpp:(.text+0x25d): undefined reference to 'AvlTree<KeyPair, std::less<KeyPair>, nil<KeyPair> >::AvlTree()'
(... a lot of errors like above ...)
collect2: ld returned 1 exit status
make[1]: ** [q1] Erro 1

What I am doing wrong here?

  • 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-22T12:12:33+00:00Added an answer on May 22, 2026 at 12:12 pm

    Assuming AvlTree.h declares a template class AvlTree<>, and AvlTree.cpp defines the implementation:

    You can’t define the implementation of template code in a separate translation unit (.cpp) — it must exist where it is used. That’s why they included it in the header. Putting the implementation in a .cpp file to be included was just a design choice to keep the .h file concise.

    (Well, technically you can put the template definition in a separate translation unit, but you must explicitly instantiate it for the template arguments you’ll be using. I’m guessing that’s not what you want to do.)

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

Sidebar

Related Questions

Having downloaded Pango and GLib from the GTK+ Project's Win32 downloads page and having
I created a new c# project and follwed the steps from this tutorial to
So, I'm trying to use boost.process library. I downloaded package from this location ,
i downloaded the 3.3.1-SNAPSHOT version to make generic url regarding this post: Pretty Faces:
I am taking help from the following link: http://www.codeproject.com/KB/cs/SMS.aspx I have Downloaded source and
I downloaded a WPFToolkit source, because I wanted to override the default generic template
I downloaded Reflector.Net and it's an .Exe outside VS. I remember (last year) when
I downloaded nUnit and TestDriven.net. I have a legacy Web Site application and I
I've downloaded the VCSharpSample pack from Microsoft and started reading on Anonymous Delegates. I
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Net; using HtmlAgilityPack; namespace sss

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.