Trouble Shooting Undefined Symbols

Atomical
Unregistered
 
Post: #1
What are the best ways to trouble shoot undefined symbols. I've got two of them, one in zeroblaster, and the other in deployment, so essentially my project is going nowhere right now. Rasp Both of them are different undefined symbols.
Quote this message in a reply
Member
Posts: 111
Joined: 2002.06
Post: #2
The major causes of undefined symbols are forgetting to add a framework to your project and forgetting to include a header file. Finding out what you're missing becomes the problem.

If you're running Mac OS X 10.4, you can enter the missing symbol in Spotlight and find every file where that symbol appears. If you don't have 10.4 and the missing symbol is in one of Apple's framework, you can search Xcode's documentation window to find the framework and header file you need.

Mark Szymczyk
http://www.meandmark.com
Quote this message in a reply
Atomical
Unregistered
 
Post: #3
They are both user defined functions. Both are included and have worked up until recently.
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #4
are you mixing C or ObjC with C++ in your project?
Quote this message in a reply
Atomical
Unregistered
 
Post: #5
How would I be mixing C and C++ incorrectly? I definitely don 't have any Objective C in it. This is under Xcode 1.1. Source code files should be .cpp and header files should be .h correct?
Quote this message in a reply
Member
Posts: 370
Joined: 2002.04
Post: #6
You could try a clean/build cycle, sometimes that magically fixes things like this.

Did you ever wonder why we had to run for shelter when the promise of a brave new world unfurled beneath the clear blue sky?
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #7
if you're using both C and C++ in the one project, you can get a situation where C and C++ think that a function is called different things if you're not careful enough with your extern "C"s... that doesn't sound like it's your problem though.
Quote this message in a reply
Atomical
Unregistered
 
Post: #8
ZeroLink: unknown symbol '__Z8load_adsPcRi'

«PROJECTNAME» has exited due to signal 6 (SIGABRT).

The first one is from files.cpp. I'm not going to post the whole file.
Quote:#include <iostream>
#include <string>
#include <cctype>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <fstream.h>
#include <dirent.h>

#include "files.h"
#include "html.h"
#include "stringutils.h"
#include "sockets.h"
#include "md5.h"

using namespace std;




storage * load_ads ( const char* file, int& count) {
count = -1;
storage *store = (storage *) malloc(sizeof(storage)*400);
int e;
int i = 0;
char *buf = (char*)malloc(1*sizeof(char)+1);
char *tmp = (char*)malloc(200*sizeof(char)+1);
buf[1] = NULL;

int fp = open (file,O_RDONLY);

if ( fp != -1 )
while ( (e = read(fp,buf,sizeof(char))) != -1 && e != 0 ) {

if ( buf[0] == '\n' ) {

store[i].data = (char*)malloc(strlen(tmp)*sizeof(char)+1);

strcpy(store[i++].data,tmp);

bzero(tmp,strlen(tmp));

} else {

strcat(tmp,buf);

}

count++;

bzero(buf,strlen(buf));
}

free(buf);
free(tmp);
return store;

}




Quote:/*
* files.h
* server
*
* Created by Adam Hallett on Sun Jul 10 2005.
* Copyright © 2005 __MyCompanyName__. All rights reserved.
*
*/







#ifndef FILES_C
#define FILES_C

using namespace std;

#include "records.h"

struct directory {
char *path;
};


void check_image_path ( char *hashpath, char *fpath, directories* database, int& dirCount );
void savefile( char* path, char *mode , char *buf);
storage * load_ads (char* file, int& count);
int file_exists (char * fileName);
int is_file ( char *path );
int lock_file ( int fp );
void unlock_file ( int fp );
char * get_hash_dir ( char *url );

char * get_hash_dir2 ( char *url );
char * md5 ( char *md5 );
int open_file ( char *path, char *mode );
int open_file ( char *path );
void write_file (int fp, char *save );
void check_dir_path ( char *dir_path , directory* directory_database );
void check_image_path ( char *hashpath, char *fpath, directories* database );
void savedata ( char *path , char* data);
#endif
Quote this message in a reply
Member
Posts: 370
Joined: 2002.04
Post: #9
You could try turning off ZeroLink for a moment to see if that changes anything or possibly creates a compile-time error with more information...

Did you ever wonder why we had to run for shelter when the promise of a brave new world unfurled beneath the clear blue sky?
Quote this message in a reply
Moderator
Posts: 1,140
Joined: 2005.07
Post: #10
I believe I see the problem: you define it in the load_ads to take a char * in the .h file, but const char * in the .cpp file. It probably considers those different enough to overload the method, than not see it when linking the files.
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #11
You can use the c++filt command-line program to turn C++ mangled symbols into something human readable:

Code:
[CookieJar:~] keith$ c++filt
__Z8load_adsPcRi
load_ads(char*, int&)
<ctrl-d to quit>

As akb825 says, char * and const char * are not the same thing, and therefore the function in the implementation file is not the one declared in the header.
Quote this message in a reply
Atomical
Unregistered
 
Post: #12
What can I say I'm learning. Now I was also having a second problem with development builds.

Quote:Ld /Users/adam/Desktop/proxyproject/server/build/server
cd /Users/adam/Desktop/proxyproject/server
/usr/bin/g++-3.3 -o /Users/adam/Desktop/proxyproject/server/build/server -L/Users/adam/Desktop/proxyproject/server/build -F/Users/adam/Desktop/proxyproject/server/build -filelist /Users/adam/Desktop/proxyproject/server/build/server.build/server.build/Objects-normal/server.LinkFileList -lstdc++ -arch ppc -prebind
ld: warning prebinding disabled because of undefined symbols
ld: Undefined symbols:
__error()


Quote:/*
* error.cpp
* server
*
* Created by Adam Hallett on Tue Aug 09 2005.
* Copyright © 2005 __MyCompanyName__. All rights reserved.
*
*/


#include <netdb.h>
#include <errno.h>
#include <stdio.h>
#include <iostream>
#include <string>
#include <cctype>
#include <signal.h>
#include "error.h"
void error(char *msg)
{
perror(msg);
exit(1);
}

const char * host_error ( ) {
const char *err;

switch (h_errno) {
case HOST_NOT_FOUND: err="host not found"; break;
case TRY_AGAIN: err="try again"; break;
case NO_RECOVERY: err="no recovery"; break;
case NO_DATA: err="no_data"; break;
default: err=NULL;
}

return err;

}


const char * http_err ( int id ) {

}

Quote:/*
* error.h
* server
*
* Created by Adam Hallett on Tue Aug 09 2005.
* Copyright © 2005 __MyCompanyName__. All rights reserved.
*
*/


#ifndef ERROR____
#define ERROR____
void error(char *msg);
const char * host_error ( );
const char * http_err ( int id );
#endif
Quote this message in a reply
Atomical
Unregistered
 
Post: #13
adam% make
g++ -c -o main.o main.cpp
g++ -c -o error.o error.cpp
g++ -c -o stringutils.o stringutils.cpp
stringutils.cpp: In function `int stripos(char*, char*, int)':
stringutils.cpp:113: warning: return-statement with no value, in function
declared with a non-void return type
g++ -c -o html.o html.cpp
g++ -c -o files.o files.cpp
g++ -c -o untitled.o untitled.cpp
g++ -c -o sockets.o sockets.cpp
sockets.cpp: In function `void dostuff(int, storage*, int)':
sockets.cpp:162: warning: invalid conversion from `void*' to `hostname*'
sockets.cpp: In function `char* get_resource(hostent*, char*, char*, char*,
int, int, char*, int&)':
sockets.cpp:445: warning: invalid conversion from `void*' to `const sockaddr*'
g++ -c -o socketspec.o socketspec.cpp
g++ -c -o auth.o auth.cpp
g++ -c -o memory.o memory.cpp
g++ -c -o md5.o md5.cpp
g++ -c -o test_htuu.o test_htuu.cpp
g++ -c -o url_string.o url_string.cpp
g++ -c -o htuu_string.o htuu_string.cpp
g++ -c -o http_fetcher.o http_fetcher.cpp
http_fetcher.cpp: In function `int http_fetch(char*, char**, char**, char**,
char**, char*, hostname**, int&)':
http_fetcher.cpp:112: warning: invalid conversion from `const char*' to `char*'
http_fetcher.cpp: In function `void http_perror(const char*)':
http_fetcher.cpp:737: warning: invalid conversion from `const char*' to `char*'
c++ -o -c -Wmissing-prototypes main.o error.o stringutils.o html.o files.o untitled.o sockets.o socketspec.o auth.o memory.o md5.o test_htuu.o url_string.o htuu_string.o http_fetcher.o
ld: Undefined symbols:
__error()
_convertedError
make: *** [all] Error 1
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Arggg SDL _main undefined. Please help! m3the01 13 4,316 Jun 20, 2007 06:51 AM
Last Post: m3the01