hoehermann / purple-gowhatsapp

Pidgin/libpurple plug-in for WhatsApp Web.
GNU General Public License v3.0
287 stars 35 forks source link

Linking issue when compiling on OSX. #185

Closed zoltan-dulac closed 7 months ago

zoltan-dulac commented 8 months ago

Hello all!

Thanks for the amazing plugin. Works like a charm in Linux -- but there are problems on my Mac.

I am trying to build on OSX Ventura 13.6 with an Intel chip (not M1). I am okay until I get to the linking stage, where I get Undefined symbols for architecture x86_64 errors (scroll near the bottom of this message to read them). Is there something I need to do to ensure this links correctly on the x86_64 chipset for OSX?

Any help here would be greatly appreciated! Here is the command output for reference:

% cmake ..
-- The C compiler identification is AppleClang 14.0.3.14030022
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /Library/Developer/CommandLineTools/usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Checking for module 'gdk-pixbuf-2.0'
--   Found gdk-pixbuf-2.0, version 2.42.10
-- Checking for module 'opusfile'
--   Found opusfile, version 0.12
-- Checking for module 'purple'
--   Found purple, version 2.14.12
-- PURPLE_INCLUDE_DIRS: /opt/local/include/libpurple;/opt/local/include/glib-2.0;/opt/local/lib/glib-2.0/include;/opt/local/include
-- PURPLE_LIBRARY_DIRS: /opt/local/lib
-- PURPLE_LIBRARIES: purple;glib-2.0;intl
-- PURPLE_PLUGIN_DIR: /opt/local/lib/purple-2
-- PURPLE_DATA_DIR: /opt/local/share
-- PIXBUF_INCLUDE_DIRS: /opt/local/include/gdk-pixbuf-2.0;/opt/local/include/libpng16;/opt/local/include;/opt/local/include/glib-2.0;/opt/local/lib/glib-2.0/include;/opt/local/include
-- OPUSFILE_INCLUDE_DIRS: /opt/local/include/opus;/opt/local/include;/opt/local/include/opus
-- OPUSFILE_LINK_LIBRARIES: /opt/local/lib/libopusfile.dylib
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/zolhawry/git/purple-gowhatsapp/build
zolhawry@WKMZTF964DFE build % cmake --build .
[  4%] Building C object src/go/CMakeFiles/purple-dummy.dir/purple-dummy.c.o
[  8%] Building C object src/go/CMakeFiles/purple-dummy.dir/__/c/constants.c.o
[ 12%] Linking C static library libpurple-dummy.a
[ 12%] Built target purple-dummy
[ 16%] Updating go modules...
go: downloading github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e
go: downloading github.com/go-sql-driver/mysql v1.6.0
go: downloading github.com/lib/pq v1.10.4
go: downloading github.com/mattn/go-sqlite3 v1.14.10
go: downloading github.com/alfg/mp4 v0.0.0-20210728035756-55ea58c08aeb
go: downloading github.com/mdp/qrterminal/v3 v3.0.0
go: downloading go.mau.fi/whatsmeow v0.0.0-20240118101534-66c756f1ba45
go: downloading golang.org/x/net v0.5.0
go: downloading google.golang.org/protobuf v1.31.0
go: downloading rsc.io/qr v0.2.0
go: downloading go.mau.fi/libsignal v0.1.0
go: downloading go.mau.fi/util v0.2.0
go: downloading golang.org/x/crypto v0.15.0
go: downloading filippo.io/edwards25519 v1.0.0
go: downloading github.com/gorilla/websocket v1.5.0
go: downloading golang.org/x/text v0.6.0
go: downloading golang.org/x/net v0.10.0
go: downloading github.com/mattn/go-sqlite3 v1.14.17
go: downloading github.com/google/go-cmp v0.5.5
go: downloading github.com/stretchr/testify v1.8.4
go: downloading golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543
go: downloading gopkg.in/yaml.v3 v3.0.1
go: downloading github.com/davecgh/go-spew v1.1.1
go: downloading github.com/pmezard/go-difflib v1.0.0
go: downloading golang.org/x/text v0.14.0
[ 20%] Generating purple-go-whatsapp.a, purple-go-whatsapp.h
[ 20%] Built target purple-go-whatsapp
[ 25%] Building C object src/c/CMakeFiles/whatsmeow.dir/init.c.o
[ 29%] Building C object src/c/CMakeFiles/whatsmeow.dir/login.c.o
[ 33%] Building C object src/c/CMakeFiles/whatsmeow.dir/qrcode.c.o
[ 37%] Building C object src/c/CMakeFiles/whatsmeow.dir/bridge.c.o
[ 41%] Building C object src/c/CMakeFiles/whatsmeow.dir/process_message.c.o
[ 45%] Building C object src/c/CMakeFiles/whatsmeow.dir/display_message.c.o
[ 50%] Building C object src/c/CMakeFiles/whatsmeow.dir/groups.c.o
[ 54%] Building C object src/c/CMakeFiles/whatsmeow.dir/blist.c.o
[ 58%] Building C object src/c/CMakeFiles/whatsmeow.dir/constants.c.o
[ 62%] Building C object src/c/CMakeFiles/whatsmeow.dir/send_message.c.o
[ 66%] Building C object src/c/CMakeFiles/whatsmeow.dir/handle_attachment.c.o
[ 70%] Building C object src/c/CMakeFiles/whatsmeow.dir/send_file.c.o
[ 75%] Building C object src/c/CMakeFiles/whatsmeow.dir/presence.c.o
[ 79%] Building C object src/c/CMakeFiles/whatsmeow.dir/options.c.o
[ 83%] Building C object src/c/CMakeFiles/whatsmeow.dir/receipt.c.o
[ 87%] Building C object src/c/CMakeFiles/whatsmeow.dir/pixbuf.c.o
[ 91%] Building C object src/c/CMakeFiles/whatsmeow.dir/commands.c.o
[ 95%] Building C object src/c/CMakeFiles/whatsmeow.dir/opusreader.c.o
[100%] Linking C shared library libwhatsmeow.dylib
Undefined symbols for architecture x86_64:
  "_CFArrayAppendValue", referenced from:
      _crypto/x509/internal/macos.x509_CFArrayAppendValue_trampoline.abi0 in purple-go-whatsapp.a(go.o)
  "_CFArrayCreateMutable", referenced from:
      _crypto/x509/internal/macos.x509_CFArrayCreateMutable_trampoline.abi0 in purple-go-whatsapp.a(go.o)
  "_CFArrayGetCount", referenced from:
      _crypto/x509/internal/macos.x509_CFArrayGetCount_trampoline.abi0 in purple-go-whatsapp.a(go.o)
  "_CFArrayGetValueAtIndex", referenced from:
      _crypto/x509/internal/macos.x509_CFArrayGetValueAtIndex_trampoline.abi0 in purple-go-whatsapp.a(go.o)
  "_CFDataCreate", referenced from:
      _crypto/x509/internal/macos.x509_CFDataCreate_trampoline.abi0 in purple-go-whatsapp.a(go.o)
  "_CFDataGetBytePtr", referenced from:
      _crypto/x509/internal/macos.x509_CFDataGetBytePtr_trampoline.abi0 in purple-go-whatsapp.a(go.o)
  "_CFDataGetLength", referenced from:
      _crypto/x509/internal/macos.x509_CFDataGetLength_trampoline.abi0 in purple-go-whatsapp.a(go.o)
  "_CFDateCreate", referenced from:
      _crypto/x509/internal/macos.x509_CFDateCreate_trampoline.abi0 in purple-go-whatsapp.a(go.o)
  "_CFErrorCopyDescription", referenced from:
      _crypto/x509/internal/macos.x509_CFErrorCopyDescription_trampoline.abi0 in purple-go-whatsapp.a(go.o)
  "_CFErrorGetCode", referenced from:
      _crypto/x509/internal/macos.x509_CFErrorGetCode_trampoline.abi0 in purple-go-whatsapp.a(go.o)
  "_CFRelease", referenced from:
      _crypto/x509/internal/macos.x509_CFRelease_trampoline.abi0 in purple-go-whatsapp.a(go.o)
  "_CFStringCreateExternalRepresentation", referenced from:
      _crypto/x509/internal/macos.x509_CFStringCreateExternalRepresentation_trampoline.abi0 in purple-go-whatsapp.a(go.o)
  "_CFStringCreateWithBytes", referenced from:
      _crypto/x509/internal/macos.x509_CFStringCreateWithBytes_trampoline.abi0 in purple-go-whatsapp.a(go.o)
  "_SecCertificateCopyData", referenced from:
      _crypto/x509/internal/macos.x509_SecCertificateCopyData_trampoline.abi0 in purple-go-whatsapp.a(go.o)
  "_SecCertificateCreateWithData", referenced from:
      _crypto/x509/internal/macos.x509_SecCertificateCreateWithData_trampoline.abi0 in purple-go-whatsapp.a(go.o)
  "_SecPolicyCreateSSL", referenced from:
      _crypto/x509/internal/macos.x509_SecPolicyCreateSSL_trampoline.abi0 in purple-go-whatsapp.a(go.o)
  "_SecTrustCreateWithCertificates", referenced from:
      _crypto/x509/internal/macos.x509_SecTrustCreateWithCertificates_trampoline.abi0 in purple-go-whatsapp.a(go.o)
  "_SecTrustEvaluateWithError", referenced from:
      _crypto/x509/internal/macos.x509_SecTrustEvaluateWithError_trampoline.abi0 in purple-go-whatsapp.a(go.o)
  "_SecTrustGetCertificateAtIndex", referenced from:
      _crypto/x509/internal/macos.x509_SecTrustGetCertificateAtIndex_trampoline.abi0 in purple-go-whatsapp.a(go.o)
  "_SecTrustGetCertificateCount", referenced from:
      _crypto/x509/internal/macos.x509_SecTrustGetCertificateCount_trampoline.abi0 in purple-go-whatsapp.a(go.o)
  "_SecTrustSetVerifyDate", referenced from:
      _crypto/x509/internal/macos.x509_SecTrustSetVerifyDate_trampoline.abi0 in purple-go-whatsapp.a(go.o)
  "_res_9_nclose", referenced from:
      _internal/syscall/unix.libresolv_res_9_nclose_trampoline.abi0 in purple-go-whatsapp.a(go.o)
  "_res_9_ninit", referenced from:
      _internal/syscall/unix.libresolv_res_9_ninit_trampoline.abi0 in purple-go-whatsapp.a(go.o)
  "_res_9_nsearch", referenced from:
      _internal/syscall/unix.libresolv_res_9_nsearch_trampoline.abi0 in purple-go-whatsapp.a(go.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[2]: *** [src/c/libwhatsmeow.dylib] Error 1
make[1]: *** [src/c/CMakeFiles/whatsmeow.dir/all] Error 2
make: *** [all] Error 2
hoehermann commented 8 months ago

Thank you for the report. I was not even aware libpurple is actually being used on MacOS. :D

I have not access to MacOS. Please try adding this to the bottom of src/c/CMakeLists.txt:

if (APPLE)
    find_library(Foundation Foundation)
    target_link_libraries(${TARGET_NAME} PUBLIC $<$<PLATFORM_ID:Darwin>:${Foundation}>)
endif()
hoehermann commented 7 months ago

Closing due to inactivity. In case the suggestion above helped (or did not), feel free to give feedback.