Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Special Interest Groups
  3. C++ Gurus
  4. [Solved]Compiler error: Undefined symbols for arhcitecture x86_64
Forum Updated to NodeBB v4.3 + New Features

[Solved]Compiler error: Undefined symbols for arhcitecture x86_64

Scheduled Pinned Locked Moved C++ Gurus
3 Posts 2 Posters 2.2k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Y Offline
    Y Offline
    Yahara
    wrote on last edited by
    #1

    Hello,

    I got a pretty nasty error when I wrote a new function today. I use it in several places in a program, so I've put that function in a separate file which I include when I need it.
    I want this function to be dynamic do some extend so I used a template for one of the parameters, which I think is the cause of all my problems.

    Probably I don't make much sense, so I hope the code bellow will shed the light on this more than I did.

    file_structures.h - this is where function header is at
    @#ifndef FILE_STRUCTURES_H
    #define FILE_STRUCTURES_H

    #include <string.h>
    #include "globals.h"

    /...
    irrelevant code here
    ...
    /

    template <class type_of_element>
    bool generate_manifest_file(short type, type_of_element element[], int n, RProject project_data);

    #endif // FILE_STRUCTURES_H
    @

    file_structures.cpp - whole definition (function's body)
    @#include "file_structures.h"
    #include "level_elements.h"

    /...
    irrelevant code here
    ...
    /

    template <class type_of_element>
    bool generate_manifest_file(short type, type_of_element element[], int n, RProject project_data)
    {
    // CODE
    }
    @

    projectcontrol.cpp - this is where I actually use/call this function
    @#include "globals.h"
    #include "file_structures.h"

    /...
    irrelevant code here
    ...
    /
    void handleFileGeneration()
    {
    /...
    irrelevant code here
    ...
    /
    if(!generate_manifest_file(0, test_element, 3, current_project))
    qDebug() << "ERROR!";
    else
    qDebug() << "YEY!";
    }

    /...
    irrelevant code here
    ...
    /
    @

    And of course also compiler output shouldn't hurt also:
    @Undefined symbols for architecture x86_64:
    "bool generate_manifest_file<terrain_tile>(short, terrain_tile*, int, RProject)", referenced from:
    ProjectControl::handleElementImport() in projectcontrol.o
    ld: symbol(s) not found for architecture x86_64
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    @

    And for additional info:
    I'm using Mac version of Qt 5.1.0,
    working on OS X 10.8.4,
    compiling with GCC / G++ version: 4.2.1,
    and no I am not using any external libraries expect for those already build in Qt.

    Thank you, for reading through all this mess,
    Yahara

    1 Reply Last reply
    0
    • K Offline
      K Offline
      koahnig
      wrote on last edited by
      #2

      Did you try to have the function's body in the header file as it is usual for template classes?

      Vote the answer(s) that helped you to solve your issue(s)

      1 Reply Last reply
      0
      • Y Offline
        Y Offline
        Yahara
        wrote on last edited by
        #3

        Thank you, that did solve my problem.

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved