I have the following problem.
I imported several c file in my iOS project (Objective-C) and all seems to be ok.
These c files performs some operations and I would to be able to call these c functions from my ViewController class.
I tried several times but I have the following error during compilation:
Undefined symbols for architecture x86_64:
“test()”, referenced from:
-[ViewController testPgnExtractButtonPressed:] in ViewController.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Please, is there someone able to give me a solution to call c functions from objective-c. Research in internet only shows how to write some simple function in a objective-c class.
Many thanks and regards,
Are you sure you are importing ALWAYS headers (.h) files and not .c files? Furtherly, when you use C files it’s better to use the natural #include than #import, which may feature a different behavior in C files (in addition to double including avoid, but you can fix that by using #ifdef s in headers file)
Many thanks for your suggestion, I have fixed the problem.
Sorry if I ask you another suggestion. I need to read/write iOS file from C functions but I can’t because this function “access(filename,R_OK)” is not able to find the file (filename is the path to a file in iOS Documents directory). The same problem I have if I try to read a file from NSBundle.
Do you have an idea how can I solve this problem?
Many thanks again and regards,
I have to make some tries to give you a good answer about that, but first absure that the path of that file when accessing it with Objective-C Core functions is the same of when accessing it using access function (the char *filename)
This is a more detailed explanation.
I created my iOS application on Xcode, I imported the c files that perform operations on text files (typically source files and dest files). First I run iOS simulator with file path on my Mac and all is running perfectly (the source file is read fine and the dest file is created fine).
Then I run the same iOS app with source and dest file on iOS: (source file is taken from nsbudle end dest file should be created on iOS Documents directory). When the application check the presence of source file with the access function it doesn’t find it and the following message is printed: unable to locate file xxxxxxx.
I hope I was clear in my explanation. Let me know if you need more details.
many thanks and regards,
Sorry, but if you want I can send you the iOS project.