Access to a static c++ field from objective-c -


i have library in c++ , did modifications want add new static variable.

but have same error.

ld /users/ricardo/library/developer/xcode/deriveddata/parlamobile-gjgrppzlpeaavrbixticgpbwnurz/build/products/debug-iphoneos/myapp.app/myapp normal arm64     cd /users/ricardo/xcode/mobile-ios     export iphoneos_deployment_target=8.0     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/iphoneos9.3.sdk -l/users/ricardo/library/developer/xcode/deriveddata/parlamobile-gjgrppzlpeaavrbixticgpbwnurz/build/products/debug-iphoneos -l/users/ricardo/xcode/mobile-ios/parlamobile/vendor/openssl/lib -f/users/ricardo/library/developer/xcode/deriveddata/parlamobile-gjgrppzlpeaavrbixticgpbwnurz/build/products/debug-iphoneos -f/users/ricardo/xcode/mobile-ios/pods/crashlytics/ios -f/users/ricardo/xcode/mobile-ios/pods/fabric/ios -f/users/ricardo/xcode/mobile-ios -f/users/ricardo/xcode/mobile-ios/parlamobile/frameworks -filelist /users/ricardo/library/developer/xcode/deriveddata/parlamobile-gjgrppzlpeaavrbixticgpbwnurz/build/intermediates/parlamobile.build/debug-iphoneos/myapp.build/objects-normal/arm64/myapp.linkfilelist -xlinker -rpath -xlinker @executable_path/frameworks -miphoneos-version-min=8.0 -dead_strip -xlinker -no_deduplicate -objc -lc++ -lz -framework crashlytics -framework fabric -framework security -framework systemconfiguration -framework uikit -fobjc-arc -fobjc-link-runtime -lsqlite3 -framework systemconfiguration -framework coredata -lz.1.2.5 -framework uikit -framework foundation -lssl -lcrypto -lpods-myapp -xlinker -dependency_info -xlinker /users/ricardo/library/developer/xcode/deriveddata/parlamobile-gjgrppzlpeaavrbixticgpbwnurz/build/intermediates/parlamobile.build/debug-iphoneos/myapp.build/objects-normal/arm64/myapp_dependency_info.dat -o /users/ricardo/library/developer/xcode/deriveddata/parlamobile-gjgrppzlpeaavrbixticgpbwnurz/build/products/debug-iphoneos/myapp.app/myapp  ld: warning: directory not found option '-f/users/ricardo/xcode/mobile-ios/parlamobile/frameworks' undefined symbols architecture arm64:   "dns::iptype", referenced from:       -[glooxbridge getiptype] in glooxbridge.o      dns::connect(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, int, gloox::logsink const&) in dns.o ld: symbol(s) not found architecture arm64 clang: error: linker command failed exit code 1 (use -v see invocation) 

this dns.h

#ifndef dns_h__ #define dns_h__  #include "macros.h" #include "logsink.h"  #ifdef __mingw32__ # include <windows.h> # include <windns.h> #endif  #ifdef have_arpa_nameser_h # include <arpa/nameser.h> #endif  #ifdef __apple__ # include <arpa/nameser_compat.h> #endif  #ifndef ns_maxdname # define ns_maxdname 1025 #endif  #ifndef ns_packetsz # define ns_packetsz 512 #endif  #ifdef have_getaddrinfo # include <sys/types.h> # include <sys/socket.h> # include <netdb.h> #endif  #include <string> #include <map>  namespace gloox {    /**    * @brief class holds number of static functions used dns related stuff.    *    * should not need use these functions directly.    *    * @author jakob schröter <js@camaya.net>    * @since 0.3    */   class gloox_api dns   {     public:       //ip type (4 or 6)       static int iptype;//nothing(0),ipv4(4),ipv6(6)       ... 

this how access variable in dns.cpp

if(sockfd!=-1){     dns::iptype = 6; } 

and objective-c class mybridge.h

#import <foundation/foundation.h> #import "remotedto.h"  @class myuserdto; @class mymessagedto; @class myroomdto;  @interface glooxbridge : nsobject<remotedtodelegate>  @property (nonatomic, readwrite) bool loggedin; @property (nonatomic, retain) nsmutabledictionary *contacts; ....  + (glooxbridge *)sharedinstance;  - (ibaction)initmainloop; - (ibaction)appearonline; - (ibaction)appearoffline; - (ibaction)logout; ...  - (int)getiptype;  @end 

mybridge.mm

#import "glooxbridge.h" #include "glooxhelper.h" #include "gloox.h" #include "dns.h"  using namespace gloox;  static glooxbridge *_instance; static glooxhelper *_helper;  @implementation glooxbridge {     int _firstmessage;     dataform *_roomconfigform;     uibackgroundtaskidentifier _backgroundtaskid; }  @synthesize loggedin = _loggedin; @synthesize contacts = _contacts; @synthesize rooms = _rooms; @synthesize lastmessages = _lastmessages; @synthesize roomparticipants = _roomparticipants;  + (glooxbridge *)sharedinstance {     @synchronized(self) {         if(!_instance) {             _instance = [[glooxbridge alloc] init];         }     }      return _instance; }  - (id)init {     if (self = [super init]) {         _loggedin = no;     }      return self; }  ...  - (int)getiptype {     //return gloox_api::dns::iptype;     return dns::iptype; } 

looks forgot defintion of variable.
(note access dns::connect in c++ undefined, suggests it's not objective-c++ issue).

add

int dns::iptype; 

to "dns.cpp" @ file scope.
(with suitable initial value if don't want zero.)


Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -