Undefined symbols while including Zxing to Xcode 4.3 + Obj-C - objective-c

I am facing some problem while including ZXingWidget to my previous iOS project.
It is a project which I started earlier using XCode4.3+ARC for iOS. For this project I need to include ZXing to scan.
I had followed the README provided.
Copy zxing into project root, add ZXingWidget.xcodeproj project
Adding link libZXingWidget.a in build phases
Added ZXingWidget to target dependencies
Header Search Paths - recursive $(SRCROOT)/zxing-read-only/iphone/ZXingWidget/Classes
Header Search Paths - non-recursive $(SRCROOT)/zxing-read-only/cpp/core/src
Import all the required iOS frameworks.
Things to note:
ZXing compiled and run properly on iphone simulator
I am getting about 66 errors about undefined symbols. (example below)
Zxing code is obtained from SVN (I also tried the zip download, same but 64 errors)
But I could not import any file directly from my code
(#import not working).
I also tried this solution with no luck.
Any other possibilities that I am missing?
Any help is appreciated!
Some error output I am getting now.
Undefined symbols for architecture i386:
"std::ios_base::Init::Init()", referenced from:
___cxx_global_var_init in libZXingWidget.a(Binarizer.o)
___cxx_global_var_init in libZXingWidget.a(BinaryBitmap.o)
___cxx_global_var_init in libZXingWidget.a(Array.o)
___cxx_global_var_init in libZXingWidget.a(BitArray.o)
___cxx_global_var_init in libZXingWidget.a(BitMatrix.o)
___cxx_global_var_init in libZXingWidget.a(BitSource.o)
___cxx_global_var_init in libZXingWidget.a(Counted.o)
...
"std::terminate()", referenced from:
zxing::Binarizer::Binarizer(zxing::Ref<zxing::LuminanceSource>) in libZXingWidget.a(Binarizer.o)
zxing::Binarizer::~Binarizer() in libZXingWidget.a(Binarizer.o)
zxing::BinaryBitmap::BinaryBitmap(zxing::Ref<zxing::Binarizer>) in libZXingWidget.a(BinaryBitmap.o)
zxing::BinaryBitmap::~BinaryBitmap() in libZXingWidget.a(BinaryBitmap.o)
zxing::BinaryBitmap::getBlackRow(int, zxing::Ref<zxing::BitArray>) in libZXingWidget.a(BinaryBitmap.o)
zxing::BinaryBitmap::getWidth() const in libZXingWidget.a(BinaryBitmap.o)
zxing::BinaryBitmap::getHeight() const in libZXingWidget.a(BinaryBitmap.o)
...
"operator delete(void*)", referenced from:
zxing::Binarizer::~Binarizer() in libZXingWidget.a(Binarizer.o)
zxing::Counted::~Counted() in libZXingWidget.a(Binarizer.o)
zxing::BinaryBitmap::~BinaryBitmap() in libZXingWidget.a(BinaryBitmap.o)
zxing::BinaryBitmap::crop(int, int, int, int) in libZXingWidget.a(BinaryBitmap.o)
zxing::BinaryBitmap::rotateCounterClockwise() in libZXingWidget.a(BinaryBitmap.o)
zxing::Counted::~Counted() in libZXingWidget.a(BinaryBitmap.o)
zxing::BitArray::~BitArray() in libZXingWidget.a(BitArray.o)
...
"___cxa_allocate_exception", referenced from:
zxing::Counted::release() in libZXingWidget.a(Binarizer.o)
zxing::Counted::release() in libZXingWidget.a(BinaryBitmap.o)
zxing::BitArray::setRange(int, int) in libZXingWidget.a(BitArray.o)
zxing::BitArray::isRange(unsigned long, unsigned long, bool) in libZXingWidget.a(BitArray.o)
zxing::BitMatrix::setRegion(unsigned long, unsigned long, unsigned long, unsigned long) in libZXingWidget.a(BitMatrix.o)
zxing::Counted::release() in libZXingWidget.a(BitMatrix.o)
zxing::BitSource::readBits(int) in libZXingWidget.a(BitSource.o)
...

You need to rename main.m to main.mm. That will tell Xcode to link with the necessary C++ libraries, which is what are missing.

Related

Undefined symbol: _swift_getOpaqueTypeConformance - React Native & SwiftUI

I'm trying to port a SwiftUI view into react native following this guide. It build fine in swift project but not in a react native project.
I'm getting the following error:
Undefined symbols for architecture x86_64:
"_swift_getOpaqueTypeConformance", referenced from:
lava.ColorWheelView.body.getter : some in ColorWheelView.o
closure #2 (SwiftUI.GeometryProxy) -> <<opaque return type of lava.ColorWheelView.makeView(SwiftUI.GeometryProxy) -> some>>.0 in lava.ColorWheelView.body.getter : some in ColorWheelView.o
associated type witness table accessor for SwiftUI.View.Body : SwiftUI.View in lava.ColorWheelView : SwiftUI.View in lava in ColorWheelView.o
l_get_witness_table qd0__7SwiftUI4ViewHD3_AaBPAAE7gesture_9includingQrqd___AA11GestureMaskVtAA0F0Rd__lFQOyAA15ModifiedContentVyAA6ZStackVyAA05TupleC0VyAJyAA06_ShapeC0VyAA9RectangleVAA5ColorVGAA12_FrameLayoutVG_AJy4lava010GuitarPickC0VAA13_OffsetEffectVGtGGAA09_PositionP0VG_AA06_EndedF0VyAA0f5StateF0VyAA08_ChangedF0VyAA04DragF0VGSo7CGPointVSgGGQo_HO in ColorWheelView.o
associated type witness table accessor for SwiftUI.View.Body : SwiftUI.View in lava.TrianglePath : SwiftUI.View in lava in GuitarPickView.o
associated type witness table accessor for SwiftUI.View.Body : SwiftUI.View in lava.GuitarPickView : SwiftUI.View in lava in GuitarPickView.o
"_swift_getTypeByMangledNameInContextInMetadataState", referenced from:
___swift_instantiateConcreteTypeFromMangledNameAbstract in ColorWheelView.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
To reproduce I made this Github repo
Copy those files in a react native project and try to build. Make sure to replace the header file import with your test project name "<Replace This>-Swift.h"
My build target is iOS 13.5 iPhone 11 Pro Max simulator.

CUDA Separable Compilation with CMake, invalid device function

I am developing a C++ application with cmake as the build system. Each component in the application builds into a static library, which the executable links to.
I am trying to link in some cuda code that is built as a separate static library, also with cmake. When I attempt to invoke the global function entry point in the cuda static library from the main application, everything seems to work fine - the cudaDeviceSynchronize that follows my global function invocation returns 0. However, the output of the kernel is not set and the call returns immediately.
I ran cuda-gdb. Despite the code being compiled with -g and -G, I was not able to break within the device function called by the kernel. So, I ran cuda-memcheck. When the kernel is launched, this message appears:
========= Program hit cudaErrorInvalidDeviceFunction (error 8) due to "invalid device function" on CUDA API call to cudaLaunchKernel.
I looked this up, and the NVIDIA docs/forum posts I read suggested this is usually due to compiling for the wrong compute capability. However, I'm running Titan V's, and the CC is correctly set to 7.0 when compiling.
I have set CUDA_SEPARABLE_COMPILATION on both the cuda library and the component in the main application that the cuda code links to per https://devblogs.nvidia.com/building-cuda-applications-cmake/. I've also tried setting CUDA_RESOLVE_DEVICE_SYMBOLS.
Here is the relevant portion of the cmake for the main application:
(kronmult_cuda is the component in the main application that links to the cuda library ${KRONLIB}. another component, kronmult, links to kronmult_cuda. Eventually, something that links to kronmult is linked to the main application).
find_package(CUDA 9.0 REQUIRED)
include_directories(${CUDA_INCLUDE_DIRS})
enable_language(CUDA)
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -arch sm_70 -g --ptxas-options=-O3")
set_source_files_properties( src/kronmult_cuda.cpp PROPERTIES LANGUAGE CUDA ) # no .cu extension
...
target_include_directories(kronmult_cuda PRIVATE ${KRON_PATH})
target_link_libraries(kronmult_cuda PRIVATE OpenMP::OpenMP_CXX PUBLIC ${KRON_LIB})
if (ASGARD_USE_CUDA)
set_target_properties(kronmult_cuda
PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
endif()
if(APPLE AND ASGARD_USE_GPU)
set_target_properties(kronmult_cuda
PROPERTIES
BUILD_RPATH ${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES})
endif ()
target_link_libraries(kronmult PRIVATE kronmult_cuda)
...
Full CMakeLists: https://github.com/bmcdanie/ASGarD/blob/feature/kronmult/CMakeLists.txt.
relevant CMakeLists portion for cuda library:
project(kronmult LANGUAGES CXX CUDA)
set(KRONSRC
[list of all sources]
)
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -arch sm_70 -g --ptxas-options=-O3")
set_source_files_properties( ${KRONSRC} PROPERTIES LANGUAGE CUDA )
add_library(kron STATIC ${KRONSRC})
target_compile_features(kron PUBLIC cxx_std_11)
set_target_properties( kron
PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
Full CmakeLists: https://github.com/project-asgard/kronmult/blob/master/CMakeLists.txt.
What am I missing here?
EDIT:
Output of cuda-gdb when I attempt to call kernel:
Thread 1 "asgard" hit Breakpoint 1, kronmult2_xbatched<double> (n=2, Aarray_=0x15551fa24800, lda=8, pX_=0x15551fa23c00, pY_=0x15551fa24400, pW_=0x15551fa24000, batchCount=128)
at /home/3bm/asgard/contrib/kronmult/src/kronmult-ext/kronmult2_xbatched.hpp:36
36 {
(cuda-gdb) step
__wrapper__device_stub_kronmult2_xbatched<double> (__cuda_0=#0x7fffffff9e1c: 2, __cuda_1=0x15551fa24800, __cuda_2=#0x7fffffff9e18: 8, __cuda_3=0x15551fa23c00,
__cuda_4=0x15551fa24400, __cuda_5=0x15551fa24000, __cuda_6=#0x7fffffff9e30: 128) at /tmp/tmpxft_0000ac33_00000000-5_kronmult_cuda.cudafe1.stub.c:40
40 /tmp/tmpxft_0000ac33_00000000-5_kronmult_cuda.cudafe1.stub.c: No such file or directory.
(cuda-gdb) step
__device_stub__Z18kronmult2_xbatchedIdEviPKPKT_iPPS0_S6_S6_i (__par0=2, __par1=0x15551fa24800, __par2=8, __par3=0x15551fa23c00, __par4=0x15551fa24400, __par5=0x15551fa24000,
__par6=128) at /tmp/tmpxft_0000ac33_00000000-5_kronmult_cuda.cudafe1.stub.c:39
39 in /tmp/tmpxft_0000ac33_00000000-5_kronmult_cuda.cudafe1.stub.c
(cuda-gdb) step
dim3::dim3 (this=0x7fffffff9d28, vx=1, vy=1, vz=1)
at /home/dg6/spack/opt/spack/linux-ubuntu18.04-x86_64/gcc-7.3.0/cuda-10.0.130-s6ervywpchxmerrju62il7xkeeamlfcv/include/vector_types.h:420
420 __host__ __device__ dim3(unsigned int vx = 1, unsigned int vy = 1, unsigned int vz = 1) : x(vx), y(vy), z(vz) {}
(cuda-gdb) step
dim3::dim3 (this=0x7fffffff9d34, vx=1, vy=1, vz=1)
at /home/dg6/spack/opt/spack/linux-ubuntu18.04-x86_64/gcc-7.3.0/cuda-10.0.130-s6ervywpchxmerrju62il7xkeeamlfcv/include/vector_types.h:420
420 __host__ __device__ dim3(unsigned int vx = 1, unsigned int vy = 1, unsigned int vz = 1) : x(vx), y(vy), z(vz) {}
(cuda-gdb) step
cudaLaunchKernel<char> (
func=0x5555555f94c0 <kronmult2_xbatched<double>(int, double const* const*, int, double**, double**, double**, int)> "UH\211\345H\203\354\060\211}\374H\211u\360\211U\370H\211M\350L\211E\340L\211M\330L\213E\330H\213}\340H\213M\350H\215U\370H\213u\360H\215E\374H\203\354\bL\215M\020AQM\211\301I\211\370H\211\307\350\355\343\377\377H\203\304\020\220\311\303UH\211\345H\203\354\060\211}\374H\211u\360\211U\370H\211M\350L\211E\340L\211M\330L\213E\330H\213}\340H\213M\350H\215U\370H\213u\360H\215E\374H\203\354\bL\215M\020AQM\211\301I\211\370H\211\307\350\267\345\377\377H\203\304\020\220\311\303UH\211\345H\203\354\060\211}\374H\211u\360\211U\370H\211M\350L\211E\340L\211", <incomplete sequence \330>..., gridDim=..., blockDim=...,
args=0x7fffffff9d40, sharedMem=0, stream=0x0)
at /home/dg6/spack/opt/spack/linux-ubuntu18.04-x86_64/gcc-7.3.0/cuda-10.0.130-s6ervywpchxmerrju62il7xkeeamlfcv/bin/..//include/cuda_runtime.h:202
202 return ::cudaLaunchKernel((const void *)func, gridDim, blockDim, args, sharedMem, stream);
(cuda-gdb) step
warning: Cuda API error detected: cudaLaunchKernel returned (0x8)
After the helpful hint from #talonmies, I suspected this was a device linking problem. I simplified my build process, included all CUDA files in one translation unit, and turned off SEPARABLE COMPILATION.
Still, I did not see a cmake_device_link.o in either my main application binary or the component that called into my cuda library. And, still had the same error. Tried setting CUDA_RESOLVE_DEVICE_SYMBOLS to no effect.
Finally, I tried building the component that calls into my cuda library as SHARED. I saw the device linking step when building the .so in my cmake output, and the program runs fine. I do not know why building SHARED fixes what I suspect was a device linking problem - will accept any answer that deciphers that?

Undefined symbols for architecture arm64 - Google Mobile Ads

I'm trying to add Google Mobile Ads SDK 7.6
But i'm getting a lot of errors, and i can't solve it. Under here i have some of the errors.
Undefined symbols for architecture arm64:
"_UITransitionContextFromViewControllerKey", referenced from:
-[GADViewControllerFullScreenSwipeAnimation animateTransition:] in GoogleMobileAds(GADViewControllerFullScreenSwipeAnimation.o)
-[GADViewControllerFullScreenSwipeAnimation animationContextForRestoringAnimationToSavedState:] in GoogleMobileAds(GADViewControllerFullScreenSwipeAnimation.o)
"_UITransitionContextToViewControllerKey", referenced from:
-[GADViewControllerFullScreenSwipeAnimation animateTransition:] in GoogleMobileAds(GADViewControllerFullScreenSwipeAnimation.o)
-[GADViewControllerFullScreenSwipeAnimation animationContextForTopToBottomAnimationPresentationWithTransitionContext:] in GoogleMobileAds(GADViewControllerFullScreenSwipeAnimation.o)
-[GADViewControllerFullScreenSwipeAnimation animationContextForBottomToTopAnimationPresentationWithTransitionContext:] in GoogleMobileAds(GADViewControllerFullScreenSwipeAnimation.o)
"_OBJC_CLASS_$_UIScrollView", referenced from:
objc-class-ref in GoogleMobileAds(GADSlot+SwipeToViewController.o)
"_OBJC_CLASS_$_UIPasteboard", referenced from:
objc-class-ref in GoogleMobileAds(GADAdView.o)
"_UIImageWriteToSavedPhotosAlbum", referenced from:
-[GADMRAIDPicture storeImage:] in GoogleMobileAds(GADMRAIDPicture.o)
"_CGSizeFromString", referenced from:
_GADCGSizeFromString in GoogleMobileAds(GADAdSize.o)
"_CATransform3DMakeRotation", referenced from:
-[GADAdView(VideoAdditions) rotateVideoToDegrees:] in GoogleMobileAds(GADAdView+VideoAdditions.o)
"_OBJC_METACLASS_$_UIGestureRecognizer", referenced from:
_OBJC_METACLASS_$_GADImpressionTicketGestureRecognizer in GoogleMobileAds(GADImpressionTicketGestureRecognizer.o)
_OBJC_METACLASS_$_GADAdViewTouchGestureRecognizer in GoogleMobileAds(GADAdViewTouchGestureRecognizer.o)
"_OBJC_CLASS_$_UIGestureRecognizer", referenced from:
_OBJC_CLASS_$_GADImpressionTicketGestureRecognizer in GoogleMobileAds(GADImpressionTicketGestureRecognizer.o)
_OBJC_CLASS_$_GADAdViewTouchGestureRecognizer in GoogleMobileAds(GADAdViewTouchGestureRecognizer.o)
"_UIViewNoIntrinsicMetric", referenced from:
-[GADBannerView intrinsicContentSize] in GoogleMobileAds(GADBannerView.o)
Thank you !
I found a solution. I had to use the #import GoogleMobileAds; instead of using #import <GoogleMobileAds/GoogleMobileAds.h>
That solved my problem.

connected to the project at Ada QT libraries

When connecting to a project on Ada QT library produces errors.
with QT; use QT;
.....
Log.
E:\GNAT\2013\qtada\qt-qchar.o:qt-qchar.adb:(.text+0x14): undefined reference to QChar1_create'
E:\GNAT\2013\qtada\qt-qchar.o:qt-qchar.adb:(.text+0x30): undefined reference toQChar2_create'
E:\GNAT\2013\qtada\qt-qchar.o:qt-qchar.adb:(.text+0x5a): undefined reference to QChar3_create'
E:\GNAT\2013\qtada\qt-qchar.o:qt-qchar.adb:(.text+0x6f): undefined reference toQChar4_create'
E:\GNAT\2013\qtada\qt-qchar.o:qt-qchar.adb:(.text+0x8b): undefined reference to QChar5_create'
E:\GNAT\2013\qtada\qt-qchar.o:qt-qchar.adb:(.text+0xa7): undefined reference toQChar6_create'
E:\GNAT\2013\qtada\qt-qchar.o:qt-qchar.adb:(.text+0xbb): undefined reference to QChar7_create'
E:\GNAT\2013\qtada\qt-qchar.o:qt-qchar.adb:(.text+0xcf): undefined reference toQChar8_create'
E:\GNAT\2013\qtada\qt-qchar.o:qt-qchar.adb:(.text+0xe3): undefined reference to QChar_latin1'
e:/gnat/2013/bin/../libexec/gcc/i686-pc-mingw32/4.7.4/ld.exe: E:\GNAT\2013\qtada\qt-qchar.o: bad reloc address 0x20 in section.eh_frame'
e:/gnat/2013/bin/../libexec/gcc/i686-pc-mingw32/4.7.4/ld.exe: final link failed: Invalid operation
collect2.exe: error: ld returned 1 exit status
gprbuild: link of main.adb failed
[2014-04-28 08:15:40] process exited with status 4 (elapsed time: 01.50s)
Are your installed QT,QTADA libraries compatible with the Mingw-Toolchain? Also regarding the bitness 32/64. The Versions of your libraries and the compile/linker command would be helpful.
You might also consider following hint:
GMP with MinGW on Windows

Mounting a network volume from OS X App

I'm trying to mount a network volume in a OS X App.
I get it to work using the FSMountServerVolume function which is deprecated. The documentation says "To mount a network volume, use NetFSMountURLAsync instead". But when I try to use this function I get the following error message:
dyld: lazy symbol binding failed: Symbol not found: _NetFSMountURLSync
Referenced from: /Users/username/Library/Developer/Xcode/DerivedData/AppName-ammmlfwhvlfxkdburfmzioformdn/Build/Products/Debug/AppName.app/Contents/MacOS/AppName
Expected in: /System/Library/Frameworks/NetFS.framework/Versions/A/NetFS
dyld: Symbol not found: _NetFSMountURLSync
Referenced from: /Users/username/Library/Developer/Xcode/DerivedData/AppName-ammmlfwhvlfxkdburfmzioformdn/Build/Products/Debug/AppName.app/Contents/MacOS/AppName
Expected in: /System/Library/Frameworks/NetFS.framework/Versions/A/NetFS
Did I forget anything? I imported the NetFS Framework.
OK, it looks like NetFSMountURLSync() etc where introduced in 10.8.
From NetFS Changes:
Added AsyncRequestID
Added NetFSMountURLAsync()
Added NetFSMountURLBlock
Added NetFSMountURLCancel()
Added NetFSMountURLSync()
Added #def kNAUIOptionAllowUI
Added #def kNAUIOptionForceUI
Added #def kNAUIOptionKey
Added #def kNAUIOptionNoUI
Added #def kNetFSMountAtMountDirKey
Therefore you are going to have to use the "old way" in 10.7 and below and the "new way" in 10.8 and above. This means making the NetFS.framework optional rather than required and the need to perform various runtime checks to see which API you need to use.