-
March 23rd, 2009, 06:09 AM
#1
Unidentified reference when incuding header file
I have three file:
Drupal.h
Drupal.cpp
install.cpp
When including the Drupal.h file in the install.cpp file and compiling, everything is 100%, but when I try to run I get the following error:
Code:
C:\DOCUME~1\andrel\LOCALS~1\Temp/ccghcaaa.o(.text+0xe):install.cpp: undefined reference to `Drupal::copy_drupal_files_WindowsXP()'
collect2: ld returned 1 exit status
When I include the Drupal.cpp file in the install.cpp file, everything works 100%. Am I doing something wrong, I'm sure I'm not supposed to include the cpp file but the h file.
See my three files below:
Drupal.h
Code:
/**
// Author: Andre Lombaard
// Date: 21/03/2009
*/
#ifndef DRUPAL_H
#define DRUPAL_H
class Drupal
{
public:
void copy_drupal_files_WindowsXP();
};
#endif
Drupal.cpp
Code:
/**
// Author: Andre Lombaard
// Date: 21/03/2009
// Class: Copy the drupal files to the server/host folder and update the database
*/
#include <iostream>
#include <windows.h>
#include "Drupal.h"
using namespace std;
/**
Autohor: Andre Lombaard
Date: 23/03/2009
Function: A function that was developed in to copy all the files contained in the drupal folder to a new destination specified on the C: drive
Operating system: Windows XP
*/
void Drupal::copy_drupal_files_WindowsXP()
{
SHFILEOPSTRUCT sf;
memset(&sf,0,sizeof(sf));
sf.hwnd = 0;
sf.wFunc = FO_COPY; //Set the wFunc member to COPY
sf.pFrom = "C:\\UEPS report manager installer\\drupal\\drupal-6.8\\*.*\0\0"; //The destination to copy from
sf.pTo = "C:\\UEPS report manager installer\\drupal\\wamp\\drupal-6.8\0\0"; //The destination to copy to
sf.fFlags = FOF_NOCONFIRMATION | FOF_NOCONFIRMMKDIR | FOF_SIMPLEPROGRESS;
int n = SHFileOperation(&sf);
if( n == 0)
{
cout << "Success\n";
}
else
{
cout << "Failed\n";
}
}
install.cpp
Code:
/**
// Author: Andre Lombaard
// Date: 21/03/2009
// Class: Execute the UEPS report manager installer application
*/
#include "Drupal.h"
using namespace std;
int main()
{
Drupal d;
d.copy_drupal_files_WindowsXP();
return 0;
}
Any help is much appreciated
-
March 23rd, 2009, 06:23 AM
#2
Re: Unidentified reference when incuding header file
Is Drupal.h in the same directory as install.cpp?
I don't see anything wrong. How are you compiling it?
-
March 23rd, 2009, 07:03 AM
#3
Re: Unidentified reference when incuding header file
Yes they are in the same directory. I'm compiling using SciTe, so I just press Ctrl+F7
-
March 23rd, 2009, 07:10 AM
#4
Re: Unidentified reference when incuding header file
install.cpp: undefined reference to `Drupal::copy_drupal_files_WindowsXP()'
collect2: ld returned 1 exit status
When including the Drupal.h file in the install.cpp file and compiling, everything is 100%, but when I try to run I get the following error:
That looks like a compilation error rather than runtime.
Are you sure you get this error after you run it?
-
March 23rd, 2009, 07:14 AM
#5
Re: Unidentified reference when incuding header file
Try manual compiling:
Code:
g++ install.cpp drupal.cpp -o install
(I agree with potatoCode).
-
March 23rd, 2009, 07:24 AM
#6
Re: Unidentified reference when incuding header file
Some compilers use "zero-link" builds where all linker dependencies are resolved at runtime. That could explain what's being seen.
They key is that .h files have nothing to do with linker errors. Those arise because you aren't compiling both source files.
-
March 23rd, 2009, 07:34 AM
#7
Re: Unidentified reference when incuding header file
Originally Posted by Lindley
Some compilers use "zero-link" builds where all linker dependencies are resolved at runtime. That could explain what's being seen.
Hi Lindley!
Aha I see, I didn't know about that.
Thanks!
-
March 23rd, 2009, 08:28 AM
#8
Re: Unidentified reference when incuding header file
Thank you Lindley
You were right, I compiled both the files and everything is working now! Guess that is why it is best practice to use a MAKEFILE right?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|