Apple Mach-O Linker Error - duplicate symbols - c++

I'm having a little trouble with an app I'm making. I researched this a bit and looked at other posts, but the fixes that they proposed don't work for me. I am running all the latest softwares.
It says:
3 duplicate symbols for architecture i386
Linker command failed with exit code 1 ( use -v to see invocation)
Ld
/Users/RileyLloyd/Library/Developer/Xcode/DerivedData/People_Bingo-eqtneohyjbwwpxclkkhkbtkcddye/Build/Products/Debug-iphonesimulator/People\
Bingo.app/People\ Bingo normal i386
cd "/Users/RileyLloyd/Documents/Xcode/People Bingo"
setenv IPHONEOS_DEPLOYMENT_TARGET 7.0
setenv PATH "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang
-arch i386 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.0.sdk
-L/Users/RileyLloyd/Library/Developer/Xcode/DerivedData/People_Bingo-eqtneohyjbwwpxclkkhkbtkcddye/Build/Products/Debug-iphonesimulator
-F/Users/RileyLloyd/Library/Developer/Xcode/DerivedData/People_Bingo-eqtneohyjbwwpxclkkhkbtkcddye/Build/Products/Debug-iphonesimulator
-filelist /Users/RileyLloyd/Library/Developer/Xcode/DerivedData/People_Bingo-eqtneohyjbwwpxclkkhkbtkcddye/Build/Intermediates/People\
Bingo.build/Debug-iphonesimulator/People\
Bingo.build/Objects-normal/i386/People\ Bingo.LinkFileList -Xlinker
-objc_abi_version -Xlinker 2 -fobjc-arc -fobjc-link-runtime -Xlinker -no_implicit_dylibs -mios-simulator-version-min=7.0 -framework CoreData -framework CoreGraphics -framework UIKit -framework
Foundation -Xlinker -dependency_info -Xlinker
/Users/RileyLloyd/Library/Developer/Xcode/DerivedData/People_Bingo-eqtneohyjbwwpxclkkhkbtkcddye/Build/Intermediates/People\
Bingo.build/Debug-iphonesimulator/People\
Bingo.build/Objects-normal/i386/People\ Bingo_dependency_info.dat -o
/Users/RileyLloyd/Library/Developer/Xcode/DerivedData/People_Bingo-eqtneohyjbwwpxclkkhkbtkcddye/Build/Products/Debug-iphonesimulator/People\
Bingo.app/People\ Bingo
duplicate symbol _OBJC_IVAR_$_CollectionViewController._cellArray in:
/Users/RileyLloyd/Library/Developer/Xcode/DerivedData/People_Bingo-eqtneohyjbwwpxclkkhkbtkcddye/Build/Intermediates/People
Bingo.build/Debug-iphonesimulator/People
Bingo.build/Objects-normal/i386/ViewController.o
/Users/RileyLloyd/Library/Developer/Xcode/DerivedData/People_Bingo-eqtneohyjbwwpxclkkhkbtkcddye/Build/Intermediates/People
Bingo.build/Debug-iphonesimulator/People
Bingo.build/Objects-normal/i386/CollectionViewController.o duplicate
symbol _OBJC_CLASS_$_CollectionViewController in:
/Users/RileyLloyd/Library/Developer/Xcode/DerivedData/People_Bingo-eqtneohyjbwwpxclkkhkbtkcddye/Build/Intermediates/People
Bingo.build/Debug-iphonesimulator/People
Bingo.build/Objects-normal/i386/ViewController.o
/Users/RileyLloyd/Library/Developer/Xcode/DerivedData/People_Bingo-eqtneohyjbwwpxclkkhkbtkcddye/Build/Intermediates/People
Bingo.build/Debug-iphonesimulator/People
Bingo.build/Objects-normal/i386/CollectionViewController.o duplicate
symbol _OBJC_METACLASS_$_CollectionViewController in:
/Users/RileyLloyd/Library/Developer/Xcode/DerivedData/People_Bingo-eqtneohyjbwwpxclkkhkbtkcddye/Build/Intermediates/People
Bingo.build/Debug-iphonesimulator/People
Bingo.build/Objects-normal/i386/ViewController.o
/Users/RileyLloyd/Library/Developer/Xcode/DerivedData/People_Bingo-eqtneohyjbwwpxclkkhkbtkcddye/Build/Intermediates/People
Bingo.build/Debug-iphonesimulator/People
Bingo.build/Objects-normal/i386/CollectionViewController.o ld: 3
duplicate symbols for architecture i386 clang: error: linker command
failed with exit code 1 (use -v to see invocation)

Two modules in your application (ViewController and CollectionViewController) have provided an implementation of class CollectionViewController. The three duplication symbols are class metadata.
There are a number of ways you might have done this:
You have two modules declaring the same class. Perhaps one is vestigial?
The #implementation CollectionViewController appears in a .h file that is included in both CollectionViewController.m and ViewController.m - or you included a .m file somewhere.

Related

OpenGL Link Error for GLFW DDS Load function

I have been working my way through the OpenGL-tutorial.org tutorial series. All has been working fine, however I have not been able to get Tutorial 5 to work in my playground executable, though it does work when run from the example tutorial 5 executable. This is true even when I copy and paste the example code over.
I receive the following errors:
Undefined symbols for architecture x86_64:
"loadDDS(char const*)", referenced from:
_main in playground.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Below is the link log:
Ld playground/playground normal x86_64
cd /Users/RufusVijayaratnam/rufus/Coding/ogl-master
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -target x86_64-apple-macos10.15 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk -L/Users/RufusVijayaratnam/rufus/Coding/ogl-master/playground -F/Users/RufusVijayaratnam/rufus/Coding/ogl-master/playground -filelist /Users/RufusVijayaratnam/rufus/Coding/OpenGL/Tutorials.build/Debug/playground.build/Objects-normal/x86_64/playground.LinkFileList -Xlinker -object_path_lto -Xlinker /Users/RufusVijayaratnam/rufus/Coding/OpenGL/Tutorials.build/Debug/playground.build/Objects-normal/x86_64/playground_lto.o -Xlinker -no_deduplicate -Wl,-search_paths_first -Wl,-headerpad_max_install_names -framework OpenGL -framework OpenGL /Users/RufusVijayaratnam/rufus/Coding/OpenGL/external/glfw-3.1.2/src/Debug/libglfw3.a /Users/RufusVijayaratnam/rufus/Coding/OpenGL/external/Debug/libGLEW_1130.a -framework Cocoa -framework OpenGL -framework IOKit -framework CoreFoundation -framework CoreVideo -Xlinker -dependency_info -Xlinker /Users/RufusVijayaratnam/rufus/Coding/OpenGL/Tutorials.build/Debug/playground.build/Objects-normal/x86_64/playground_dependency_info.dat -o /Users/RufusVijayaratnam/rufus/Coding/ogl-master/playground/playground
So the error appears to be that when the function loadDDS() is called that it is not found. I am unsure as to why this is. The function is declared in texture.ccp which is in a folder (called 'common'), along with texture.hpp. texture.hpp has the code below:
#ifndef TEXTURE_HPP
#define TEXTURE_HPP
// Load a .DDS file using GLFW's own loader
GLuint loadDDS(const char * imagepath);
#endif
In playground.cpp there is:
include<texture.hpp>
Why can't loadDDS() be found, even though I have set the working directory of the playground function to the same as that for Tutorial 5, and the code in playground.ccp and 'tutorial05.ccp' is exactly the same?
for the playground executable (doesn't work)
# User playground add_executable(playground
playground/playground.cpp
common/shader.cpp
common/shader.hpp )
and finally for tutorial 5 (does work)
# Tutorial 5
add_executable(tutorial05_textured_cube
tutorial05_textured_cube/tutorial05.cpp
common/shader.cpp
common/shader.hpp
common/texture.cpp
common/texture.hpp
So I'm making the educated guess that loadDDS() is implemented in texture.cpp, and since you did not add this file, it won't be compiled, and the resulting object file won't be linked, and the symbol will just not be found.

Compiling GCC-5.0 OS X Lion dyld: Symbol not found: __ZNKSt11logic_error4whatEv

I'm trying to install gcc-5.0 from source on my OS X 10.7.5 using the (Apple built) /usr/bin/gcc-4.2 and the appropriate versions of gcc dependencies (gmp,mpfr,mpc) which are installed at /usr/local.
The reason I'm trying to (re)install gcc-5.0 is because I want to install it into a separate folder like /usr/local/gcc-5.0 so that I can choose to use or not us it easily by setting it into the PATH environment variable. The /configure script is (initiated from an empty gcc-5.0-build folder)
../gcc-5.0.0/configure --prefix=/usr/local/gcc-5.0.0 --with-gmp=/usr/local/lib --with-mpfr=/usr/local/lib --with-mpc=/usr/local/lib --enable-languages=c,c++
After make and about 1GB of compiled files I get this error (truncated)
dyld: Symbol not found: __ZNKSt11logic_error4whatEv
Referenced from: <my-build-dir>/x86_64-apple-darwin11.4.0/libstdc++-v3/src/.libs/libstdc++.6.dylib
Expected in: flat namespace
After browsing many webpages and posts in Stackoverflow, I've tried various things like:
adding LDFLAGS="-flat_namespace"before ./configure
compiling with Apple built gcc-4.2 instead of gcc-5.0
but no luck I still end up with this error.
When I check the libstdc++.6.dylib on the presence of __ZNKSt11logic_error4whatEv
nm -g x86_64-apple-darwin11.4.0/libstdc++-v3/src/.libs/libstdc++.6.dylib | grep __ZNKSt11logic_error4whatEv
It returns:
U __ZNKSt11logic_error4whatEv
so itcontains the symbol in question It doesn't contain the symbol in question (The U means Undefined)
otool -hv x86_64-apple-darwin11.4.0/libstdc++-v3/src/.libs/libstdc++.6.dylib
returns
Mach header
magic cputype cpusubtype caps filetype ncmds sizeofcmds flags
MH_MAGIC_64 X86_64 ALL 0x00 DYLIB 13 2560 NOUNDEFS DYLDLINK TWOLEVEL WEAK_DEFINES BINDS_TO_WEAK NO_REEXPORTED_DYLIBS
The DYLDLINK TWOLEVEL means that it's two-level namespace lib.
Questions :
1- In the message Expected in: flat namespace does it mean that the compiler wants absolutely only the flat namespace library? I mean is it absolutely not possible to use this two-level namespace lib? After a comment by #G.M. the symbol is not defined in the library in question and that makes the absence or presence of flat namespace irrelevant because it is the content of the library which causes the problem, not its type.
2- What should I do compile the gcc-5.0 ?
Update 23.March.2021
Upon the answer suggesting hiding the symbols, I've added
export CFLAGS="-fvisibility=hidden"
onto the ~/.bash_profile deleted the build folder all over, configured again using
../gcc-5.0.0-20150224/configure --prefix=/usr/local/gcc-5.0.0 --enable-languages=c,c++
and after make has created 532MB of compiled files, it stopped by the strip: symbols names listed in:libgcc-darwin.10.4.ver not in libgcc_s.dylib type of error. Here is how it stopped:
/Users/thompson/Downloads/gcc-5.0.0-20150224-mybuild/./gcc/xgcc -B/Users/thompson/Downloads/gcc-5.0.0-20150224-mybuild/./gcc/ -B/usr/local/gcc-5.0.0/x86_64-apple-darwin11.4.2/bin/ -B/usr/local/gcc-5.0.0/x86_64-apple-darwin11.4.2/lib/ -isystem /usr/local/gcc-5.0.0/x86_64-apple-darwin11.4.2/include -isystem /usr/local/gcc-5.0.0/x86_64-apple-darwin11.4.2/sys-include -O2 -g -O2 -fvisibility=hidden -DIN_GCC -W -Wall -Wwrite-strings -Wcast-qual -Wno-format -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition -isystem ./include -pipe -fno-common -g -DIN_LIBGCC2 -fbuilding-libgcc -fno-stack-protector -dynamiclib -nodefaultlibs -install_name /usr/local/gcc-5.0.0/lib/libgcc_s.1.dylib -single_module -o ./libgcc_s.dylib -Wl,-exported_symbols_list,libgcc.map -compatibility_version 1 -current_version 1.0 -g -O2 -fvisibility=hidden -B./ _muldi3_s.o _negdi2_s.o _lshrdi3_s.o _ashldi3_s.o _ashrdi3_s.o _cmpdi2_s.o _ucmpdi2_s.o _clear_cache_s.o _trampoline_s.o __main_s.o _absvsi2_s.o _absvdi2_s.o _addvsi3_s.o _addvdi3_s.o _subvsi3_s.o _subvdi3_s.o _mulvsi3_s.o _mulvdi3_s.o _negvsi2_s.o _negvdi2_s.o _ctors_s.o _ffssi2_s.o _ffsdi2_s.o _clz_s.o _clzsi2_s.o _clzdi2_s.o _ctzsi2_s.o _ctzdi2_s.o _popcount_tab_s.o _popcountsi2_s.o _popcountdi2_s.o _paritysi2_s.o _paritydi2_s.o _powisf2_s.o _powidf2_s.o _powixf2_s.o _powitf2_s.o _mulsc3_s.o _muldc3_s.o _mulxc3_s.o _multc3_s.o _divsc3_s.o _divdc3_s.o _divxc3_s.o _divtc3_s.o _bswapsi2_s.o _bswapdi2_s.o _clrsbsi2_s.o _clrsbdi2_s.o _fixunssfsi_s.o _fixunsdfsi_s.o _fixunsxfsi_s.o _fixsfdi_s.o _fixdfdi_s.o _fixxfdi_s.o _fixunssfdi_s.o _fixunsdfdi_s.o _fixunsxfdi_s.o _floatdisf_s.o _floatdidf_s.o _floatdixf_s.o _floatundisf_s.o _floatundidf_s.o _floatundixf_s.o _fixsfti_s.o _fixdfti_s.o _fixxfti_s.o _fixtfti_s.o _fixunssfti_s.o _fixunsdfti_s.o _fixunsxfti_s.o _fixunstfti_s.o _floattisf_s.o _floattidf_s.o _floattixf_s.o _floattitf_s.o _floatuntisf_s.o _floatuntidf_s.o _floatuntixf_s.o _floatuntitf_s.o _divdi3_s.o _moddi3_s.o _udivdi3_s.o _umoddi3_s.o _udiv_w_sdiv_s.o _udivmoddi4_s.o darwin-64_s.o cpuinfo_s.o sfp-exceptions_s.o addtf3_s.o divtf3_s.o eqtf2_s.o getf2_s.o letf2_s.o multf3_s.o negtf2_s.o subtf3_s.o unordtf2_s.o fixtfsi_s.o fixunstfsi_s.o floatsitf_s.o floatunsitf_s.o fixtfdi_s.o fixunstfdi_s.o floatditf_s.o floatunditf_s.o fixtfti_s.o fixunstfti_s.o floattitf_s.o floatuntitf_s.o extendsftf2_s.o extenddftf2_s.o extendxftf2_s.o trunctfsf2_s.o trunctfdf2_s.o trunctfxf2_s.o enable-execute-stack_s.o unwind-dw2_s.o unwind-dw2-fde-darwin_s.o unwind-sjlj_s.o unwind-c_s.o emutls_s.o libgcc.a -lc
ld: warning: cannot export hidden symbol ___ashldi3 from darwin-64_s.o
ld: warning: cannot export hidden symbol ___ashrdi3 from darwin-64_s.o
ld: warning: cannot export hidden symbol ___clzsi2 from darwin-64_s.o
ld: warning: cannot export hidden symbol ___cmpdi2 from darwin-64_s.o
<truncated>
ld: warning: cannot export hidden symbol ___fixunstfsi from fixunstfsi_s.o
ld: warning: cannot export hidden symbol ___floatsitf from floatsitf_s.o
<truncated>
ld: warning: cannot export hidden symbol ___enable_execute_stack from enable-execute-stack_s.o
<truncated>
ld: warning: cannot export hidden symbol ___emutls_register_common from emutls_s.o
MLIBS=`/Users/thompson/Downloads/gcc-5.0.0-20150224-mybuild/./gcc/xgcc -B/Users/thompson/Downloads/gcc-5.0.0-20150224-mybuild/./gcc/ -B/usr/local/gcc-5.0.0/x86_64-apple-darwin11.4.2/bin/ -B/usr/local/gcc-5.0.0/x86_64-apple-darwin11.4.2/lib/ -isystem /usr/local/gcc-5.0.0/x86_64-apple-darwin11.4.2/include -isystem /usr/local/gcc-5.0.0/x86_64-apple-darwin11.4.2/sys-include --print-multi-lib | sed -e 's/;.*$//'` ; \
for mlib in $MLIBS ; do \
cp ../${mlib}/libgcc/${mlib}/libgcc_s.dylib \
./libgcc_s.1.dylib_T_${mlib} || exit 1 ; \
done
lipo -output libgcc_s.1.dylib \
-create libgcc_s.1.dylib_T*
rm libgcc_s.1.dylib_T*
<truncated>
strip: symbols names listed in: <source-folder>/libgcc/config/i386/libgcc-darwin.10.4.ver not in: </Users/thompson/Downloads/gcc-5.0.0-20150224-mybuild>/x86_64-apple-darwin11.4.2/libgcc/libgcc_s.dylib
___ashldi3
___ashrdi3
___clzsi2
___cmpdi2
___ctzsi2
___divdi3
___enable_execute_stack
___gcc_personality_v0
___lshrdi3
___moddi3
___muldi3
___negdi2
___paritysi2
___popcountsi2
___ucmpdi2
___udivdi3
___udivmoddi4
___umoddi3
make[3]: *** [libgcc_ext.10.4.dylib] Error 1
make[2]: *** [all-stage1-target-libgcc] Error 2
I suffered the same error while running my application in release mode.
After two days searching I manage to resolve it by turning the Symbols Hidden by Default off in the dynamic library project build settings.
Hope this is helpful to you and others with the same error.

iOS Framework: image not found

When trying to embed a shared Framework generated from CMake into an Xcode iOS app, I encounter the following issue:
dyld: Library not loaded: /Users/jones/Documents/project/build/ios/foo.framework/foo
Referenced from: /var/Containers/Bundle/Application//myapp.app/myapp
Reason: image not found
It seems like it has an incorrect "dylib id", but I am not sure what that means exactly. Note that my framework appears in the "Frameworks" folder of the app (the built "Product" that is installed on the phone).
Checking my app with otool -L, I see:
myapp:
/Users/name/Documents/project/build/ios/foo.framework/foo
/System/Library/Frameworks/Foundation.framework/Foundation
/usr/lib/libobjc.A.dylib
...
Which seems to show that the path to my framework is wrong in the app. But I can't seem to change it from Xcode.
On the Apple dev forum, somebody mentions changing DYLIB_INSTALL_NAME_BASE to #rpath from Build Settings -> Dynamic Library Install Name Base, but it doesn't solve my problem.
The linker log coming from Xcode looks like so (maybe easier to read here:
Ld /Users/jones/Library/Developer/Xcode/DerivedData/myapp-gngqigiisiapqjflqkjjadvdbneu/Build/Products/Debug-iphoneos/myapp.app/myapp normal arm64
cd /Users/jones/Documents/project/ios-playground/myapp
export IPHONEOS_DEPLOYMENT_TARGET=11.2
export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS11.2.sdk -L/Users/jones/Library/Developer/Xcode/DerivedData/myapp-gngqigiisiapqjflqkjjadvdbneu/Build/Products/Debug-iphoneos -F/Users/jones/Library/Developer/Xcode/DerivedData/myapp-gngqigiisiapqjflqkjjadvdbneu/Build/Products/Debug-iphoneos -F/Users/jones/Documents/project/ios-playground/myapp -F/Users/jones/Documents/project/ios-playground/myapp/Frameworks -filelist /Users/jones/Library/Developer/Xcode/DerivedData/myapp-gngqigiisiapqjflqkjjadvdbneu/Build/Intermediates.noindex/myapp.build/Debug-iphoneos/myapp.build/Objects-normal/arm64/myapp.LinkFileList -Xlinker -rpath -Xlinker #executable_path/Frameworks -miphoneos-version-min=11.2 -dead_strip -Xlinker -object_path_lto -Xlinker /Users/jones/Library/Developer/Xcode/DerivedData/myapp-gngqigiisiapqjflqkjjadvdbneu/Build/Intermediates.noindex/myapp.build/Debug-iphoneos/myapp.build/Objects-normal/arm64/myapp_lto.o -Xlinker -export_dynamic -Xlinker -no_deduplicate -fembed-bitcode-marker -stdlib=libc++ -fobjc-link-runtime -L/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos -Xlinker -add_ast_path -Xlinker /Users/jones/Library/Developer/Xcode/DerivedData/myapp-gngqigiisiapqjflqkjjadvdbneu/Build/Intermediates.noindex/myapp.build/Debug-iphoneos/myapp.build/Objects-normal/arm64/myapp.swiftmodule -framework foo -Xlinker -dependency_info -Xlinker /Users/jones/Library/Developer/Xcode/DerivedData/myapp-gngqigiisiapqjflqkjjadvdbneu/Build/Intermediates.noindex/myapp.build/Debug-iphoneos/myapp.build/Objects-normal/arm64/myapp_dependency_info.dat -o /Users/jones/Library/Developer/Xcode/DerivedData/myapp-gngqigiisiapqjflqkjjadvdbneu/Build/Products/Debug-iphoneos/myapp.app/myapp
How can I fix this?
There is actually a way to set the "install_name_dir" in CMake:
set_target_properties(dynamicFramework PROPERTIES
...
BUILD_WITH_INSTALL_RPATH TRUE
INSTALL_NAME_DIR #rpath
)

xcode c++ project with lua lib got link error

First, I create a c++ console project.
Then, I download the lua5.2.0 from lua.org, then make the lib use [make macosx test] and got the liblua.a.
Finally, I import the lua src into project and drag the liblua.a in project, write some demo code and compile,but get the link error, I confirm there has no grammar error.
Ld /Users/luocaixin/Library/Developer/Xcode/DerivedData/LuaAdapter-dwqvzxkkhfmcsneiftgqstjfemts/Build/Products/Debug/LuaAdapter normal x86_64
cd /Users/luocaixin/Desktop/xcodeWS1/LuaAdapter
export MACOSX_DEPLOYMENT_TARGET=10.10
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk -L/Users/luocaixin/Library/Developer/Xcode/DerivedData/LuaAdapter-dwqvzxkkhfmcsneiftgqstjfemts/Build/Products/Debug -L/Users/luocaixin/Desktop/xcodeWS1/LuaAdapter/Lua.5.2.0/src -F/Users/luocaixin/Library/Developer/Xcode/DerivedData/LuaAdapter-dwqvzxkkhfmcsneiftgqstjfemts/Build/Products/Debug -filelist /Users/luocaixin/Library/Developer/Xcode/DerivedData/LuaAdapter-dwqvzxkkhfmcsneiftgqstjfemts/Build/Intermediates/LuaAdapter.build/Debug/LuaAdapter.build/Objects-normal/x86_64/LuaAdapter.LinkFileList -mmacosx-version-min=10.10 -stdlib=libc++ -llua -Xlinker -dependency_info -Xlinker /Users/luocaixin/Library/Developer/Xcode/DerivedData/LuaAdapter-dwqvzxkkhfmcsneiftgqstjfemts/Build/Intermediates/LuaAdapter.build/Debug/LuaAdapter.build/Objects-normal/x86_64/LuaAdapter_dependency_info.dat -o /Users/luocaixin/Library/Developer/Xcode/DerivedData/LuaAdapter-dwqvzxkkhfmcsneiftgqstjfemts/Build/Products/Debug/LuaAdapter
duplicate symbol _main in:
/Users/luocaixin/Library/Developer/Xcode/DerivedData/LuaAdapter-dwqvzxkkhfmcsneiftgqstjfemts/Build/Intermediates/LuaAdapter.build/Debug/LuaAdapter.build/Objects-normal/x86_64/lua.o
/Users/luocaixin/Library/Developer/Xcode/DerivedData/LuaAdapter-dwqvzxkkhfmcsneiftgqstjfemts/Build/Intermediates/LuaAdapter.build/Debug/LuaAdapter.build/Objects-normal/x86_64/luac.o
duplicate symbol _main in:
/Users/luocaixin/Library/Developer/Xcode/DerivedData/LuaAdapter-dwqvzxkkhfmcsneiftgqstjfemts/Build/Intermediates/LuaAdapter.build/Debug/LuaAdapter.build/Objects-normal/x86_64/lua.o
/Users/luocaixin/Library/Developer/Xcode/DerivedData/LuaAdapter-dwqvzxkkhfmcsneiftgqstjfemts/Build/Intermediates/LuaAdapter.build/Debug/LuaAdapter.build/Objects-normal/x86_64/main.o
ld: 2 duplicate symbols for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I want to know what cause this error and how to import lua in xcode c++
project correctly.
Did you read the error? It's telling you what's wrong: you have more than one main function. You've included two object files that contain a main function (lua, luac) and probably have one in your test app, too. You need to leave those files out of your project. They are the reference command line interpreter and compiler, respectively. You don't include them if you're embedding Lua as a library.

apple mach o linker error creating basic AI CC Plugin

there are quite a no. of question on this point. But none of them can guide a solution to my issue. I am trying to create a plugin for Adobe Illustrator CC in XCode Version 6.3.2 (6D2105). Following their official guidelines to create a basic "HelloWorld" plugin giving this linker error.
Error:
Ld /Users/Barun/Adobe\ Illustrator\ CC\ 2015\ SDK/samplecode/output/mac/debug/HelloWorld.bundle/Contents/MacOS/HelloWorld normal x86_64
cd "/Users/Barun/Adobe Illustrator CC 2015 SDK/samplecode/HelloWorld"
export MACOSX_DEPLOYMENT_TARGET=10.9
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -arch x86_64 -bundle -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk -L/Users/Barun/Adobe\ Illustrator\ CC\ 2015\ SDK/samplecode/output/mac/debug -F/Users/Barun/Adobe\ Illustrator\ CC\ 2015\ SDK/samplecode/output/mac/debug -filelist /Users/Barun/Library/Developer/Xcode/DerivedData/HelloWorld-fzhjlvdzxxobzagznysauclanlgg/Build/Intermediates/HelloWorld.build/Debug/HelloWorld.build/Objects-normal/x86_64/HelloWorld.LinkFileList -mmacosx-version-min=10.9 -dead_strip -stdlib=libc++ -Xlinker -dependency_info -Xlinker /Users/Barun/Library/Developer/Xcode/DerivedData/HelloWorld-fzhjlvdzxxobzagznysauclanlgg/Build/Intermediates/HelloWorld.build/Debug/HelloWorld.build/Objects-normal/x86_64/HelloWorld_dependency_info.dat -o /Users/Barun/Adobe\ Illustrator\ CC\ 2015\ SDK/samplecode/output/mac/debug/HelloWorld.bundle/Contents/MacOS/HelloWorld
Undefined symbols for architecture x86_64:
"_CFStringCreateWithCharacters", referenced from:
ai::UnicodeString::as_CFString(__CFAllocator const*) const in IAIUnicodeString.o
"_CFStringGetCharactersPtr", referenced from:
ai::UnicodeString::UnicodeString(__CFString const* const&) in IAIUnicodeString.o
"_CFStringGetLength", referenced from:
ai::UnicodeString::UnicodeString(__CFString const* const&) in IAIUnicodeString.o
"_CFStringGetCharacters", referenced from:
ai::UnicodeString::UnicodeString(__CFString const* const&) in IAIUnicodeString.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Looks like the linking error coming from IAIUnicodeString.cpp file, which is a support file provided by the sdk. So I am not having idea to what need to be change there.
I was successful to build FreeGrid and DrawArt project provided with the SDK as sample. I have also checked all the build settings with FreeGrid to my HelloWorld project, no mismatch from that side too.
The project set up can be found in Github.
From Adobe Forum https://forums.adobe.com/message/7723859#7723859:
Add to project settings:
BuildPhases>Link Binary With Libraries: CoreFoundation.framework