Error: " Undefined symbols for architecture x86_64:
"f(int, int, int const (*) [8], int const (*) [8], int*, int*)", referenced from:
_main in main.o "
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I tried running the exact same code on Visual Studio 2010, and it worked! Any idea why it doesn't work here? My Mac is 64bit. Thanks!
Here's the code on the files that's giving the error:
#include <iostream>
using namespace std;
int p,q;
int f( int, int,const int [][8],const int [][8], int [],int []);
This happens if you haven't provided an implementation of your f(..) function.
In your main.cpp file, simply implement the function, like:
int f( int, int,const int [][8],const int [][8], int [],int [])
{
// Do stuff...
}
Related
Xcode 6 GM and its LLVM 6 give this linking error:
Undefined symbols for architecture i386:
"_fopen$UNIX2003", referenced from:
_BIO_new_file in libcrypto.a(bss_file.o)
_file_ctrl in libcrypto.a(bss_file.o)
_open_console in libcrypto.a(ui_openssl.o)
"_fputs$UNIX2003", referenced from:
_write_string in libcrypto.a(ui_openssl.o)
_read_string in libcrypto.a(ui_openssl.o)
"_fwrite$UNIX2003", referenced from:
_send_fp_chars in libcrypto.a(a_strex.o)
_write_fp in libcrypto.a(b_dump.o)
_file_write in libcrypto.a(bss_file.o)
_file_puts in libcrypto.a(bss_file.o)
"_strerror$UNIX2003", referenced from:
_ERR_load_ERR_strings in libcrypto.a(err.o)
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Now, this answer suggests adding an ad-hoc .c file which, for the case above, would be:
#include <stdio.h>
#include <string.h>
FILE *fopen$UNIX2003( const char *filename, const char *mode )
{
return fopen(filename, mode);
}
size_t fwrite$UNIX2003( const void *a, size_t b, size_t c, FILE *d )
{
return fwrite(a, b, c, d);
}
void fputs$UNIX2003(const char *restrict c, FILE *restrict f)
{
fputs(c, f);
}
char *strerror$UNIX2003(int errnum)
{
return strerror(errnum);
}
It 'works', but is this the best (or even advisable) approach?
As you guessed, no, that would not be an advisable approach to fix your LLVM linker woes in Xcode 6. Instead, assuming you're developing for iOS, what you need to do is rebuild OpenSSL for the new iOS 8 SDK. Here's a good project that will help you do that.
in case this can save anyone some time, there's I've found to fix this specific linkers issues (adding this to any any cpp file):
extern "C"{
size_t fwrite$UNIX2003( const void *a, size_t b, size_t c, FILE *d )
{
return fwrite(a, b, c, d);
}
char* strerror$UNIX2003( int errnum )
{
return strerror(errnum);
}
time_t mktime$UNIX2003(struct tm * a)
{
return mktime(a);
}
double strtod$UNIX2003(const char * a, char ** b) {
return strtod(a, b);
}
}
I'm trying to use CBLAS ATLAS. I'm a beginner. I have the following C code.
// tmp.cpp file
#include<stdio.h>
#include<stdlib.h>
#include<cblas.h>
int main(void){
float x[2] = {6,2};
float *y = (float *)malloc(2*sizeof(float));
const int n = 2;
const int incx = 1;
const int incy = 1;
float a = 5.4;
y[0] = 4.2; y[1] = 4.5;
cblas_saxpy(n,a,x,incx,y,incy);
free(y);
}
I installed the ATLAS library following the video http://youtu.be/DvLSr6zN0pU?t=6m5s and the next video "part3". However, I have no FORTRAN compiler, so I configure with
$../ATLAS/confiugre --nof77
The installation process took place as described in the video.
iMac:Desktop sotero$ ls /usr/local/atlas/include
atlas cblas.h clapack.h
iMac:Desktop sotero$ ls /usr/local/atlas/lib/
libatlas.a libcblas.a liblapack.a libptcblas.a
I tried compiling with this result
iMac:Desktop sotero$ c++ tmp.cpp
tmp.cpp:3:18: error: cblas.h: No such file or directory
tmp.cpp: In function ‘int main()’:
tmp.cpp:14: error: ‘cblas_saxpy’ was not declared in this scope
I read how to make the link to the website http://math-atlas.sourceforge.net/errata.html#LINK and I have the following to compile
iMac:Desktop sotero$ c++ tmp.cpp -L/usr/local/atlas/lib/ -lcblas -latlas -I/usr/local/atlas/include/
Undefined symbols:
"cblas_saxpy(int, float, float const*, int, float*, int)", referenced from:
_main in ccPop12J.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
I do not know how I should compile. I just need to level one BLAS. I've been looking to compile if you do link to the ATLAS library, but I'm lost.
How I can fix it?
My question is in regards to using OpenSSL on Mac via GCC.
#include <stdio.h>
#include <openssl/rand.h>
int main()
{
unsigned char key[128];
Rand_bytes(key,128);
return 0;
}
I have the following code, that I am trying to compile with GCC. Here is what I enter into the command line
gcc -o ossl ossl.c -lcrypto -lssl
However I get the following error.
Undefined symbols for architecture x86_64:
"_Rand_bytes", referenced from:
_main in cc2hf0Ij.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
I am not experienced when it comes to using openssl. Why am I receiving Undefined symbols for architecture x86_64?
int main()
{
unsigned char key[128];
Rand_bytes(key,128);
return 0;
}
Try RAND_bytes:
int main()
{
unsigned char key[128];
int rc = RAND_bytes(key,sizeof(key));
if(rc != 1)
/* Handle failure */
...
OPENSSL_cleanse(key,sizeof(key));
return 0;
}
The OpenSSL docs are at RAND_bytes(3).
I just installed CppUTest on my MAC using brew as indicated by the guide.
It failed when I tried to build the example cpp.
TEST_GROUP(FirstTestGroup)
{
};
TEST(FirstTestGroup, FirstTest)
{
FAIL("Fail me!");
}
I guess it is because the header file which define those macros are not included. So I add include as below:
#include "CppUTest/TestHarness.h"
#include "CppUTest/TestOutput.h"
TEST_GROUP(FirstTestGroup)
{
};
TEST(FirstTestGroup, FirstTest)
{
FAIL("Fail me!");
}
Now I get bunch of errors.
Undefined symbols for architecture x86_64: "UtestShell::assertTrue(bool, char const*, char const*, char const*, int)", referenced from: vtable for TEST_FirstTestGroup_FirstTest_TestShellin ccNDwnbv.o
The error you are getting is a linker error and it suggests that you are not linking the CppUTest library. It is hard to actually say what is wrong because your question is missing the Makefiles. Could you explain how you have compiled the example?
I wrote a hello world program to see how curses library works.
Here is my program:
/Users/snihalani/dev/daas at 10:10AM
➜ cat main.c
#include <stdio.h>
#include <stdlib.h>
#include <curses.h>
int main(void)
{
int returnValue = 0;
while(1)
{
printf("I got %d\n", getch());
}
return 0;
}
I ran gcc main.c
I got
/Users/snihalani/dev/daas at 10:14AM
➜ gcc main.c
Undefined symbols for architecture x86_64:
"_stdscr", referenced from:
_main in ccEvUdhx.o
"_wgetch", referenced from:
_main in ccEvUdhx.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
I don't what's going wrong. Can anyone please help?
Nevermind. I had to add -lcurses option while compiling.