I've been having some trouble with the installed version of libsasl2 (Cyrus SASL).
In particular, it seems that the local headers and sasl_version report version 2.1.26, but no symbol is provided for the global function sasl_client_done.
I'm pretty sure I'm supposed to have that symbol because:
It's there in the provided sasl/sasl.h header
The cyrsus sasl NEWS file lists "Implemented sasl_client_done()/sasl_server_done()" as a 2.1.24 feature
It's there everywhere that provides 2.1.26 outside of Yosemite
For a reproduction:
note that the sample below prints
"impl: 'Cyrus SASL', version: 33619994, major: 2, minor: 1, step: 26"
the sample compiles and executes on a linux install with the same library version after uncommenting the code
the uncommented code produces a link error on yosemite
Undefined symbols for architecture x86_64:
"_sasl_client_done", referenced from:
_main in foo-072675.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
invoking the compiler with:
clang -Wall -Werror -lsasl2 -o foo foo.c -v
with clang -v of:
Apple LLVM version 6.0 (clang-600.0.54) (based on LLVM 3.5svn)
Target: x86_64-apple-darwin14.0.0
Thread model: posix
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang" -cc1 -triple x86_64-apple-macosx10.10.0 -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -main-file-name foo.c -mrelocation-model pic -pic-level 2 -mdisable-fp-elim -masm-verbose -munwind-tables -target-cpu core2 -target-linker-version 241.9 -v -resource-dir /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/6.0 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk -Wall -Werror -fdebug-compilation-dir /Users/jcarey/work -ferror-limit 19 -fmessage-length 0 -stack-protector 1 -mstackrealign -fblocks -fobjc-runtime=macosx-10.10.0 -fencode-extended-block-signature -fdiagnostics-show-option -vectorize-slp -o /var/folders/wq/jypwqgv976n0db5l5qxw900r0000gq/T/foo-92054e.o -x c foo.c
clang -cc1 version 6.0 based upon LLVM 3.5svn default target x86_64-apple-darwin14.0.0
ignoring nonexistent directory "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/local/include"
ignoring nonexistent directory "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/Library/Frameworks"
#include "..." search starts here:
#include <...> search starts here:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/6.0/include
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/System/Library/Frameworks (framework directory)
End of search list.
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld" -demangle -dynamic -arch x86_64 -macosx_version_min 10.10.0 -syslibroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk -o foo -lsasl2 /var/folders/wq/jypwqgv976n0db5l5qxw900r0000gq/T/foo-92054e.o -lSystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/6.0/lib/darwin/libclang_rt.osx.a
Undefined symbols for architecture x86_64:
"_sasl_client_done", referenced from:
_main in foo-92054e.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
And the code in question:
#include <sasl/sasl.h>
#include <stdio.h>
#include <stdint.h>
int main(int argc, char ** argv) {
const char *impl;
int version;
uint32_t buf;
uint16_t major;
uint8_t minor;
uint8_t step;
sasl_version(&impl, &version);
buf = version;
major = buf >> 24;
minor = (buf << 8) >> 24;
step = (buf << 24) >> 24;
printf("impl: '%s', version: %d, major: %d, minor: %d, step: %d\n", impl, version, major, minor, step);
/*
{
int (* scd)(void);
scd = &sasl_client_done;
printf("sasl_client_done: %p\n", scd);
}
*/
return 0;
}
I'm thinking that something's screwy with the way cyrus sasl got packaged for Yosemite (using a symbol list from Mavericks perhaps?).
As a matter of interest, I just checked with 10.10.4 and I see the symbol is now there:
$ nm /usr/lib/libsasl2.dylib |grep sasl_client_done
000000000000724a T _sasl_client_done
The sample code now works fine (with the commented section now uncommented). The same Cyrus SASL version is still returned though:
impl: 'Cyrus SASL', version: 33619994, major: 2, minor: 1, step: 26
sasl_client_done: 0x7fff8e3dc24a
Related
I'm following an online course related to curl. However, I met some problems.
My building statement is:
gcc -Wall web-server.c -o web-server1 -lcurl
This is the code in web-server.c
#include <stdio.h>
#include <stdlib.h>
#include <curl/curl.h>
int main(void){
CURL *curl = NULL;
CURLcode res;
curl = curl_easy_init();
curl_easy_setops(curl, CURLOPT_URL, "http://www.google.com");
res = curl_easy_perform(curl);
if (res != CURLE_OK){
print("curl easy perform error res = %d",res);
return 1;
}
curl_easy_cleanup(curl);
return 0;
}
And the error message is:
Undefined symbols for architecture x86_64:
"_curl_easy_setops", referenced from:
_main in web-server-afa9ad.o
"_print", referenced from:
_main in web-server-afa9ad.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Thank you guys so much
My operating system is MacOs 10.14.6
My gcc's version
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 10.0.1 (clang-1001.0.46.4)
Target: x86_64-apple-darwin18.7.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
Found CUDA installation: /usr/local/cuda, version unknown
Detailed error message
"/Library/Developer/CommandLineTools/usr/bin/ld" -demangle -lto_library
/Library/Developer/CommandLineTools/usr/lib/libLTO.dylib -no_deduplicate -
dynamic -arch x86_64 -macosx_version_min 10.14.0 -o web-server
/var/folders/j2/jrqt57vj73s0jc8mjc2mddf40000gn/T/web-server-14b13c.o -lcurl
-lSystem
/Library/Developer/CommandLineTools/usr/lib/clang/10.0.1/lib/darwin/libclan
g_rt.osx.a
I have source file
#include <lua.h>
#include <lauxlib.h>
#include <stdlib.h>
#include <stdio.h>
#define BUFSIZE 1024
int main() {
char line[BUFSIZE];
lua_State *L = lua_open();
while (fgets(line, sizeof(line), stdin) != 0) {
lua_dostring(L, line);
}
lua_close(L);
exit(0);
}
Then I run gcc luac.c, got an error.
Undefined symbols for architecture x86_64:
"_lua_close", referenced from:
_main in luac-9bbdf6.o
"_lua_dostring", referenced from:
_main in luac-9bbdf6.o
"_lua_open", referenced from:
_main in luac-9bbdf6.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
It seems like that I have no lua.h in my /usr/local/include folder. But it have.
ls -al /usr/local/include/lua.h
-rw-r--r--# 1 root admin 11K Apr 3 16:23 /usr/local/include/lua.h
And I have
ls -al /usr/local/lib/liblua.a
-rw-r--r-- 1 root admin 150448 Apr 3 16:23 /usr/local/lib/liblua.a
The gcc search path
gcc -Xlinker -v
(#)PROGRAM:ld PROJECT:ld64-305
configured to support archs: armv6 armv7 armv7s arm64 i386 x86_64 x86_64h armv6m armv7k armv7m armv7em (tvOS)
Library search paths:
/usr/lib
/usr/local/lib
Framework search paths:
/Library/Frameworks/
/System/Library/Frameworks/
...
Why gcc says error, can you tell me.
Updated:
The problem is gcc default doesn't add lua lib?
I use gcc luac.c -llua -llualib, works.
I have some code utilizing TEMP_FAILURE_RETRY and I cannot build it. I have defined _GNU_SOURCE and included unistd.h in that order.
Running gcc -Wall -v archunix5a_2.c -o archunix5a_2 gives the following output:
Apple LLVM version 8.0.0 (clang-800.0.42.1)
Target: x86_64-apple-darwin16.3.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
"/Library/Developer/CommandLineTools/usr/bin/clang" -cc1 -triple x86_64-apple-macosx10.12.0 -Wdeprecated-objc-isa-usage -Werror=deprecated-objc-isa-usage -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -discard-value-names -main-file-name archunix5a_2.c -mrelocation-model pic -pic-level 2 -mthread-model posix -mdisable-fp-elim -masm-verbose -munwind-tables -target-cpu penryn -target-linker-version 274.2 -v -dwarf-column-info -debugger-tuning=lldb -resource-dir /Library/Developer/CommandLineTools/usr/bin/../lib/clang/8.0.0 -Wall -fdebug-compilation-dir /Users/mateuszsadowski/Documents/programowanie/nauka/C/SOP/4 -ferror-limit 19 -fmessage-length 59 -stack-protector 1 -fblocks -fobjc-runtime=macosx-10.12.0 -fencode-extended-block-signature -fmax-type-align=16 -fdiagnostics-show-option -fcolor-diagnostics -o /var/folders/fp/qqgmt88x247bd712wbbw8wh80000gn/T/archunix5a_2-7cb96f.o -x c archunix5a_2.c
clang -cc1 version 8.0.0 (clang-800.0.42.1) default target x86_64-apple-darwin16.3.0
#include "..." search starts here:
#include <...> search starts here:
/usr/local/include
/Library/Developer/CommandLineTools/usr/bin/../lib/clang/8.0.0/include
/Library/Developer/CommandLineTools/usr/include
/usr/include
/System/Library/Frameworks (framework directory)
/Library/Frameworks (framework directory)
End of search list.
archunix5a_2.c:113:13: warning: implicit declaration of
function 'TEMP_FAILURE_RETRY' is invalid in C99
[-Wimplicit-function-declaration]
if (TEMP_FAILURE_RETRY(fsync(fd)) == -1)
^
1 warning generated.
"/Library/Developer/CommandLineTools/usr/bin/ld" -demangle -dynamic -arch x86_64 -macosx_version_min 10.12.0 -o archunix5a_2 /var/folders/fp/qqgmt88x247bd712wbbw8wh80000gn/T/archunix5a_2-7cb96f.o -lSystem /Library/Developer/CommandLineTools/usr/bin/../lib/clang/8.0.0/lib/darwin/libclang_rt.osx.a
Undefined symbols for architecture x86_64:
"_TEMP_FAILURE_RETRY", referenced from:
_cleanup in archunix5a_2-7cb96f.o
_main in archunix5a_2-7cb96f.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [archunix5a_2] Error 1
I'd appreciate any help.
As i said earlier mac osx doesn't support most of the glib libraries. if you want to use TEMP_FAILURE_RETRY you can try the following
don't forget to include unistd. read more from here
here with this macro
#include <unistd.h> // for TEMP_FAILURE_RETRY
#ifndef TEMP_FAILURE_RETRY
#define TEMP_FAILURE_RETRY(exp) \
({ \
decltype(exp) _rc; \
do { \
_rc = (exp); \
} while (_rc == -1 && errno == EINTR); \
_rc; \
})
#endif
i hope this helps
We were given course work to create the game Mine Sweeper. We are still early in the semester so this homework shouldn't be too difficult.
We were given header and source files that are to be used for the visual part of the program.
Main problem is that I can't compile these files on my Mac. Here is what I get:
$ gcc mineSweeper.c -I.
Undefined symbols for architecture x86_64:
"_colorPrint", referenced from:
_main in mineSweeper-4b9486.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Also tried this:
$ gcc mineSweeper.c -I. -arch i386
Undefined symbols for architecture i386:
"_colorPrint", referenced from:
_main in mineSweeper-0938b1.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
gcc version:
gcc --version
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 6.0 (clang-600.0.54) (based on LLVM 3.5svn)
Target: x86_64-apple-darwin13.4.0
Thread model: posix
OSX version:
Software OS X 10.9.5 (13F34)
And finally the code we were provided with:
//colorPrint.h
//defines possible colors for the foreground color.
typedef enum
{
FG_Def = 0,
FG_Black = 30,
FG_Red,
FG_Green,
FG_Yellow,
FG_Blue,
FG_Magenta,
FG_Cyan,
FG_White
}fgColor;
//defines possible colors for the background color.
//BG_Def prints with the default background color of the terminal.
typedef enum
{
BG_Def = 0,
BG_Black = 40,
BG_Red,
BG_Green,
BG_Yellow,
BG_Blue,
BG_Magenta,
BG_Cyan,
BG_White
}bgColor;
//defines possible additional attributes for the color printing.
//normally, you would use ATT_Def.
typedef enum
{
ATT_Def = 0,
ATT_Bright = 1,
ATT_Underline = 4,
ATT_Reverse = 7,
ATT_Hidden = 8,
ATT_Scratch = 9
}attribute;
//clears the screen completely.
void clearScreen();
//prints a format string with its arguments (like printf!),
//in the specified foreground color, background color, and attribute.
void colorPrint(fgColor fg, bgColor bg, attribute att, char* format,...);
//colorPrint.c
#include <stdio.h>
#include <colorPrint.h>
#include <stdarg.h>
void clearScreen()
{
printf("\e[1;1H\e[2J");
}
void colorPrint(fgColor fg, bgColor bg, attribute att, char* format,...)
{
va_list args;
if(bg != BG_Def)
printf("\e[%d;%d;%dm",att,fg,bg);
else
printf("\e[%d;%dm",att,fg);
va_start (args, format);
vprintf(format, args);
va_end (args);
printf("\e[0m");
}
There is another header and code for receiving the char from user but I'm assuming linking it is irrelevant.
Any sort of help is welcome.. thanks in advance :)
PS. I also have a PC if it helps to switch to windows.
PPS. I'm keeping VirtualBox as a last resort.
You're trying to compile and link mineSweeper.c into a final executable on its own, but that file is not a complete program, it depends on a function defined in another file.
You either need to compile and link all the files in one step:
gcc mineSweep.c colourPrint.c
or compile each file separately and then link the objects:
gcc -c mineSweeper.c
gcc -c colorPrint.c
gcc mineSweeper.o colorPrint.o
I'm surprised your course didn't explain how to compile programs consisting of more than one file.
A simple makefile will ease the process:
mineSweeper: mineSweeper.o colorPrint.o
$(CC) $^ $(LDLIBS) -o $#
I have a C-Code generated by the Simulink Coder that I need to use in a C S-function.
This may sound a bit strange but I need this Code to be executed multiple times within the s-function before writing the outputs of the s-function (it's an evolutionary algorithm that needs to simulate a prediction for a lot of individuals before evaluation and ranking...but those details do not really matter).
The Problem is that I seem to have a problem with the 64bit instruction set when trying to mex my code.
I am taking the generated erg_main.c as an example on how to interact with the generated code:
/*
* File: ert_main.c
*
* Code generated for Simulink model 'Peltier_model'.
*
* Model version : 1.14
* Simulink Coder version : 8.5 (R2013b) 08-Aug-2013
* C/C++ source code generated on : Thu Apr 3 18:01:46 2014
*
* Target selection: ert.tlc
* Embedded hardware selection: 32-bit Generic
* Emulation hardware selection:
* Differs from embedded hardware (MATLAB Host)
* Code generation objective: Debugging
* Validation result: Passed (0), Warning (1), Error (0)
*/
#include <stdio.h> /* This ert_main.c example uses printf/fflush */
#include "Peltier_model.h" /* Model's header file */
#include "rtwtypes.h"
/*
* Associating rt_OneStep with a real-time clock or interrupt service routine
* is what makes the generated code "real-time". The function rt_OneStep is
* always associated with the base rate of the model. Subrates are managed
* by the base rate from inside the generated code. Enabling/disabling
* interrupts and floating point context switches are target specific. This
* example code indicates where these should take place relative to executing
* the generated code step function. Overrun behavior should be tailored to
* your application needs. This example simply sets an error status in the
* real-time model and returns from rt_OneStep.
*/
void rt_OneStep(void)
{
static boolean_T OverrunFlag = 0;
/* Disable interrupts here */
/* Check for overrun */
if (OverrunFlag) {
rtmSetErrorStatus(Peltier_model_M, "Overrun");
return;
}
OverrunFlag = TRUE;
/* Save FPU context here (if necessary) */
/* Re-enable timer or interrupt here */
/* Set model inputs here */
/* Step the model */
Peltier_model_step();
/* Get model outputs here */
/* Indicate task complete */
OverrunFlag = FALSE;
/* Disable interrupts here */
/* Restore FPU context here (if necessary) */
/* Enable interrupts here */
}
/*
* The example "main" function illustrates what is required by your
* application code to initialize, execute, and terminate the generated code.
* Attaching rt_OneStep to a real-time clock is target specific. This example
* illustates how you do this relative to initializing the model.
*/
int_T main(int_T argc, const char *argv[])
{
/* Unused arguments */
(void)(argc);
(void)(argv);
/* Initialize model */
Peltier_model_initialize();
/* Attach rt_OneStep to a timer or interrupt service routine with
* period 0.01 seconds (the model's base sample time) here. The
* call syntax for rt_OneStep is
*
* rt_OneStep();
*/
printf("Warning: The simulation will run forever. "
"Generated ERT main won't simulate model step behavior. "
"To change this behavior select the 'MAT-file logging' option.\n");
fflush((NULL));
while (rtmGetErrorStatus(Peltier_model_M) == (NULL)) {
/* Perform other application tasks here */
}
/* Disable rt_OneStep() here */
/* Terminate model */
Peltier_model_terminate();
return 0;
}
/*
* File trailer for generated code.
*
* [EOF]
*/
For now I am just trying to initialize my model using the Peltier_model_initialize(); and including those headers from the erg_main.c
trying to mex this results in the following:
**************************************************************************
Warning: Neither -compatibleArrayDims nor -largeArrayDims is selected.
Using -compatibleArrayDims. In the future, MATLAB will require
the use of -largeArrayDims and remove the -compatibleArrayDims
option. For more information, see:
http://www.mathworks.com/help/matlab/matlab_external/upgrading-mex-files-to-use-64-bit-api.html
**************************************************************************
-> mexopts.sh sourced from directory (DIR = $PREF_DIR)
FILE = /Users/JoachimSA/.matlab/R2013b/mexopts.sh
----------------------------------------------------------------
-> MATLAB = /Applications/MATLAB_R2013b.app
-> CC = xcrun -sdk macosx10.9 clang
-> CC flags:
CFLAGS = -fno-common -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk -mmacosx-version-min=10.9 -fexceptions
CDEBUGFLAGS = -g
COPTIMFLAGS = -O2 -DNDEBUG
CLIBS = -L/Applications/MATLAB_R2013b.app/bin/maci64 -lmx -lmex -lmat -lstdc++
arguments = -DMX_COMPAT_32
-> CXX = xcrun -sdk macosx10.9 clang++
-> CXX flags:
CXXFLAGS = -fno-common -fexceptions -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk -mmacosx-version-min=10.9
CXXDEBUGFLAGS = -g
CXXOPTIMFLAGS = -O2 -DNDEBUG
CXXLIBS = -L/Applications/MATLAB_R2013b.app/bin/maci64 -lmx -lmex -lmat -lstdc++
arguments = -DMX_COMPAT_32
-> FC = gfortran
-> FC flags:
FFLAGS = -fexceptions -m64 -fbackslash
FDEBUGFLAGS = -g
FOPTIMFLAGS = -O
FLIBS = -L/Applications/MATLAB_R2013b.app/bin/maci64 -lmx -lmex -lmat -L -lgfortran -L -lgfortranbegin
arguments = -DMX_COMPAT_32
-> LD = xcrun -sdk macosx10.9 clang
-> Link flags:
LDFLAGS = -arch x86_64 -Wl,-syslibroot,/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk -mmacosx-version-min=10.9 -bundle -Wl,-exported_symbols_list,/Applications/MATLAB_R2013b.app/extern/lib/maci64/mexFunction.map
LDDEBUGFLAGS = -g
LDOPTIMFLAGS = -O
LDEXTENSION = .mexmaci64
arguments =
-> LDCXX =
-> Link flags:
LDCXXFLAGS =
LDCXXDEBUGFLAGS =
LDCXXOPTIMFLAGS =
LDCXXEXTENSION =
arguments =
----------------------------------------------------------------
-> xcrun -sdk macosx10.9 clang -c -I/Applications/MATLAB_R2013b.app/rtw/c/src -I/Users/JoachimSA/Documents/WICHTIG/Diplomarbeit/Matlab_FIles/Peltier_Codegen/Peltier_model_ert_rtw -I/Applications/MATLAB_R2013b.app/extern/include -I/Applications/MATLAB_R2013b.app/simulink/include -DMATLAB_MEX_FILE -fno-common -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk -mmacosx-version-min=10.9 -fexceptions -DMX_COMPAT_32 -O2 -DNDEBUG "CC_IMEA.c"
-> xcrun -sdk macosx10.9 clang -c -I/Applications/MATLAB_R2013b.app/rtw/c/src -I/Users/JoachimSA/Documents/WICHTIG/Diplomarbeit/Matlab_FIles/Peltier_Codegen/Peltier_model_ert_rtw -I/Applications/MATLAB_R2013b.app/extern/include -I/Applications/MATLAB_R2013b.app/simulink/include -DMATLAB_MEX_FILE -fno-common -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk -mmacosx-version-min=10.9 -fexceptions -DMX_COMPAT_32 -O2 -DNDEBUG "CC_Opt_Objectives.c"
-> xcrun -sdk macosx10.9 clang -c -I/Applications/MATLAB_R2013b.app/rtw/c/src -I/Users/JoachimSA/Documents/WICHTIG/Diplomarbeit/Matlab_FIles/Peltier_Codegen/Peltier_model_ert_rtw -I/Applications/MATLAB_R2013b.app/extern/include -I/Applications/MATLAB_R2013b.app/simulink/include -DMATLAB_MEX_FILE -fno-common -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk -mmacosx-version-min=10.9 -fexceptions -DMX_COMPAT_32 -O2 -DNDEBUG "CC_System_Utils.c"
-> xcrun -sdk macosx10.9 clang -c -I/Applications/MATLAB_R2013b.app/rtw/c/src -I/Users/JoachimSA/Documents/WICHTIG/Diplomarbeit/Matlab_FIles/Peltier_Codegen/Peltier_model_ert_rtw -I/Applications/MATLAB_R2013b.app/extern/include -I/Applications/MATLAB_R2013b.app/simulink/include -DMATLAB_MEX_FILE -fno-common -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk -mmacosx-version-min=10.9 -fexceptions -DMX_COMPAT_32 -O2 -DNDEBUG "CC_Opt_SystemCabin.c"
-> xcrun -sdk macosx10.9 clang -c -I/Applications/MATLAB_R2013b.app/rtw/c/src -I/Users/JoachimSA/Documents/WICHTIG/Diplomarbeit/Matlab_FIles/Peltier_Codegen/Peltier_model_ert_rtw -I/Applications/MATLAB_R2013b.app/extern/include -I/Applications/MATLAB_R2013b.app/simulink/include -DMATLAB_MEX_FILE -fno-common -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk -mmacosx-version-min=10.9 -fexceptions -DMX_COMPAT_32 -O2 -DNDEBUG "CC_Optimiser.c"
-> xcrun -sdk macosx10.9 clang -O -arch x86_64 -Wl,-syslibroot,/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk -mmacosx-version-min=10.9 -bundle -Wl,-exported_symbols_list,/Applications/MATLAB_R2013b.app/extern/lib/maci64/mexFunction.map -o "CC_Optimiser.mexmaci64" CC_IMEA.o CC_Opt_Objectives.o CC_System_Utils.o CC_Opt_SystemCabin.o CC_Optimiser.o -L/Applications/MATLAB_R2013b.app/bin/maci64 -lmx -lmex -lmat -lstdc++
Undefined symbols for architecture x86_64:
"_Peltier_model_initialize", referenced from:
_CC_Opt_SystemCabin in CC_Opt_SystemCabin.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
mex: link of ' "CC_Optimiser.mexmaci64"' failed.
Unable to complete successfully.
Error in build_mex_files (line 6)
mex -v ...
Error in run (line 63)
evalin('caller', [script ';']);
Do I really have a problem with my 6bit version or am I just not handling the code right ?
Thanks a lot for the help !
The OP discovered that all source files need to be specified on the mex command.
This can cause compilation to succeed, but linking to fail, if all the necessary declarations are included by the main source file.
Here is some additional information from the Linking Multiple Files section of "Building MEX-Files" on the MathWorks website:
You can combine multiple source files, object files, and file libraries to build a binary MEX-file. To do this, list the additional files, with their file extensions, separated by spaces. The name of the MEX-file is the name of the first file in the list.
The following command combines multiple files of different types into a binary MEX-file called circle.ext, where ext is the extension corresponding to the current platform:
mex circle.c square.obj rectangle.c shapes.lib
As it says above, put the file with mexFunction as the first in the list so that the MEX-file gets the name from that file.
The mex help page has a section "Build MEX-File from Multiple Source Files" with a similar example, although with Fortran source:
mex -largeArrayDims fulltosparse.F loadsparse.F
The MEX-file name is fulltosparse because fulltosparse.F is the first file on the command line.