I try to compile the picoc project into xcode. No external libraries, just .c and .h files that I imported in the Command Line Tool C project.
All .c files compile without issue, but when XCode is linking, I get these messages:
Undefined symbols for architecture x86_64:
"_BasicIOInit", referenced from:
_PicocInitialise in platform.o
"_CStdOut", referenced from:
_PrintSourceTextErrorLine in platform.o
_PlatformVPrintf in platform.o
"_MathFunctions", referenced from:
_IncludeInit in include.o
"_MathSetupFunc", referenced from:
_IncludeInit in include.o
"_PicocPlatformScanFile", referenced from:
_IncludeFile in include.o
...
The command giving the error is the following:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -v -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk -L/Users/laurent/Library/Developer/Xcode/DerivedData/Pico-dhfwbamkhiyphjcwuncbwjsyjlax/Build/Products/Debug -F/Users/laurent/Library/Developer/Xcode/DerivedData/Pico-dhfwbamkhiyphjcwuncbwjsyjlax/Build/Products/Debug -filelist /Users/laurent/Library/Developer/Xcode/DerivedData/Pico-dhfwbamkhiyphjcwuncbwjsyjlax/Build/Intermediates/Pico.build/Debug/Pico.build/Objects-normal/x86_64/Pico.LinkFileList -mmacosx-version-min=10.8 -o /Users/laurent/Library/Developer/Xcode/DerivedData/Pico-dhfwbamkhiyphjcwuncbwjsyjlax/Build/Products/Debug/Pico
The Pico.LinkFileList file contains properly the list of all necessary .o files.
As all the unfound functions are in the properly compiled .c files (and compiled as .o), what should I do to avoid these errors ?
Thanks.
Those symbols are in clibrary.c; you must have missed it from the list of source files to compile.
Your next question will doubtless be about libraries to link the executable with, and to solve that I would suggest you look at the Makefile.
Adding Pico to the Target Dependencies list worked for me after the same situation. (from Pico i mean the xcode project folder from where we have created library)
reference :
https://github.com/bulldog2011/pico
In case it can help someone, I found out that some #ifdef commands were excluding the functions to be compiled.
Related
I have a header file included in the main but when I compile the main, I have an error saying that the linker failed.
I tried to find the object files but I cannot find them.
I think the problem may come from my machine. I am kind of a beginner so I don't know how to solve this
When I try compiling my code I get this error:
Undefined symbols for architecture x86_64:
"_intClassic", referenced from:
_main in main-53b7e4.o
"_intQuadrature", referenced from:
_main in main-53b7e4.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
#zwol #JonathanLeffer I have 3 files in my project main.c, integral.h
and integral.c. integral.c contains the code of the functions
intClassic and intQuadrature that allow me to calculate different
types of integral. In integral.h I declared the functions and
structures I use. Finally in the main I included integral.h .
Also $ gcc -o output file1.o file2.o can this command help me ?
In the same directory as your files, try running the command
gcc main.c integral.c -o integral
This should take the 2 files and compile them into a program called ./integral
I'm rather unused to C, and completely new to compiling bigger projects, and I'm having problems trying to build GNU Archimedes.
I tried the ./configure and make approach, as well as simply executing gcc -lm archimedes.c -o archimedes in the src/ directory, as the documentation suggests. Both give a similar error message:
Undefined symbols for architecture x86_64:
"_MM2", referenced from:
_ParabMEP2D in ccwORAXj.o
_Hole_MEP2D in ccwORAXj.o
"_creation", referenced from:
_EMC in ccwORAXj.o
"_rnd", referenced from:
_MCdevice_config in ccwORAXj.o
_scat in ccwORAXj.o
_EMC in ccwORAXj.o
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status
MM2, rnd, and creation are functions contained in one of many .h files in src/. Every solution to similar sounding problems had issues linking multiple compiled .c files together, but in this case, there's only one .c file.
If it's relevant, the name of the .o file in the error changes with every try.
I've tried building it under macOS (with both clang and gcc, the latter installed via Homebrew) and Fedora Linux, with similar results.
What am I doing wrong? I hope this is the right place to ask, but I have no idea where else to turn. I'm grateful for suggestions.
Thanks in advance and have a good day!
In the folder /archimedes-2.0.1/src/ go through all header files (.h) and change every "inline" to say "static inline".
This fix was found by Alexander Vogt. His original post is linked to below:
https://lists.gnu.org/archive/html/archimedes-discuss/2017-11/msg00000.html
The problem has to do with compatibility issues between older and newer versions of c compilers.
I have a MATLAB function that has signal processing and machine learning and I wanted to test it on another OS like linux. So I use codegen to generate C code for that function. When I come to run it (predictActivityFromSignalBuffer) on the command line, this is what I get:
MacBook-Pro-2:predictActivityFromSignalBuffer kareem$ gcc predictActivityFromSignalBuffer.c
Undefined symbols for architecture x86_64:
"_featuresFromBuffer", referenced from:
_predictActivityFromSignalBuffer in predictActivityFromSignalBuffer-1a1886.o
"_main", referenced from:
implicit entry/start for main executable
"_mynn", referenced from:
_predictActivityFromSignalBuffer in predictActivityFromSignalBuffer-1a1886.o
"_rtIsNaN", referenced from:
_predictActivityFromSignalBuffer in predictActivityFromSignalBuffer-1a1886.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
What is this error telling me exactly? I have no idea how to debug this or where to start/look.
Did you really just call
$ gcc predictActivityFromSignalBuffer.c
without any other dependencies? Usually there come a lot of other files with a code generation that have to be linked.
I do not know what you have done to produce your .c file. I recommend to use the coder wizard by typing
coder
in the Matlab command window. This will guide you through the whole process of code generation and also offers a lot of support and testing possibilities. You can also choose to compile your functions to ready-to-use DLL libraries or executatables. Just have a look at it.
I try to add gsoap in my application.
I built gsoap for i386.
Created c code with under commands:
wsdl2h -c -s -o soap.h soap.wsdl
soapcpp2 -c -C soap.h
I got files. After this I tried to include these to my app.
I added to my project in xCode. Also I added 6 libraries(libgsoap.a,libgsoap++.a,libgsoapck.a, libgsoapck++.a, libgsoapssl.a, libgsoapssl++.a). I added libraries in Target => Build phases => Link binary with libraries.
But I got error....
ld: duplicate symbol .....
I thought it happened cause in file soapClientLib.c was it:
#ifndef WITH_NOGLOBAL
#define WITH_NOGLOBAL
#endif
#define SOAP_FMAC3 static
#include "soapC.c"
#include "soapClient.c"
Comments for these was:
Use this file in your project build instead of the two files soapC.c and soapClient.c. This hides the serializer functions and avoids linking problems when linking multiple clients and servers
I removed it content.
But after this I got next error...
Undefined symbols for architecture i386:
"_namespaces", referenced from:
_soap_init_LIBRARY_VERSION_REQUIRED_20812 in libgsoap.a(libgsoap_a-stdsoap2.o)
(maybe you meant: _soap_set_namespaces, _soap_set_local_namespaces )
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
And Now I have no idea...
I used gsoap in windows and I added it to my project for 5 minutes. But I wasted much time to add it in mac os.
Can you help me?
I resolved my problem!
I had to do ./configure with keys --disable-namespaces.
Thank you.
But I steal don't understand sense of the file soapClientLib.c.
I know, that this is an old question, but I've just spent an entire evening figuring this out.
Here is a quote from this conversation (another link):
The soapcpp2-generated xyz.nsmap file should be #include'd in your code. It
contains a global XML namespace mapping (or binding) table.
The reason for including this separately is that there are scenarios where the
namespace mapping table is customized or shared.
For instance, I used a C++ classes, generated with soapcpp2 -i <my_header.h>. One of generated files is a <my_service_name>Service.cpp. To get rid of the _namespaces issue I had to #include "<my_service_name>.nsmap" in it.
As for the soapClientLib.c, I's like to quote that conversation again:
Please do not use soapClientLib.c in your build unless you want to combine
multiple separately-generated clients/server codes. This means that the
soapClientLib.c do not include the shared serializers for SOAP headers and
faults.
This problem can be solved with changing compiler filename from gcc to g++.
GCC:
gcc calcmain.cpp soapC.cpp soapcalcProxy.cpp -I/opt/local/include -lgsoap++ -L/opt/local/lib
...
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
G++:
g++ calcmain.cpp soapC.cpp soapcalcProxy.cpp -I/opt/local/include -lgsoap++ -L/opt/local/lib
All OK
Yet you can make it compilable under gcc, with adding an gcc option -lstdc++:
gcc calcmain.cpp soapC.cpp soapcalcProxy.cpp -I/opt/local/include -lgsoap++ -L/opt/local/lib -lstdc++
All OK
Undefined symbols for architecture i386:
"_OBJC_CLASS_$_Reachability", referenced from:
objc-class-ref in FirstViewController.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I've looked over FirstViewController, reachability.h and reachability.m - It's clearly defined! And I've even added SystemConfiguration.Framework, as well as Reachability.m is in the compile list.
Any ideas? I'm losing my mind!
Pic attached.
http://i.imgur.com/uw4Zb.png
Try to remove references to Reachability.h and Reachability.m files from your xCode project. - Make sure it disappears from Compile Sources.
Search you project's folder to make sure you don't have duplicates for Reachability.h and Reachability.m files in it
Command+Shift+K to clean the project;
Add Reachability.h and Reachability.m back to the xCode project;
Hope this will help.