Forum > macOS / Mac OS X

Cannot compile simple example with libcurl on MacOS with M1 cpu

(1/2) > >>

ydd:
project file:


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---program teststream;uses libcurl;var hCurl: pCurl;begin  hCurl := curl_easy_init;end.
compile log:

--- Quote ---Project checks, Hints: 1
Note: passing compiler option -M twice with different values
Hint: (11030) Start of reading config file /Users/yd/Lazarus/v1.8.2n/fpc/bin/aarch64-darwin/fpc.cfg
Hint: (11031) End of reading config file /Users/yd/Lazarus/v1.8.2n/fpc/bin/aarch64-darwin/fpc.cfg
Free Pascal Compiler version 3.3.1-r49155 [2021/04/09] for aarch64
Copyright (c) 1993-2021 by Florian Klaempfl and others
(1002) Target OS: Darwin for AArch64
(3104) Compiling teststream.pp
/Volumes/Projects/Tests/Lazarus/libcurl/teststream.pp(43,5) Note: (5027) Local variable "hCurl" is assigned but never used
(9001) Assembling (pipe) /Volumes/Projects/Tests/Lazarus/libcurl/lib/aarch64-darwin/teststream.s
(9015) Linking /Volumes/Projects/Tests/Lazarus/libcurl/teststream
Undefined symbols for architecture arm64:
  "_curl_easy_init", referenced from:
      _PASCALMAIN in teststream.o
ld: symbol(s) not found for architecture arm64
Error: (9013) Error while linking
Fatal: (10026) There were 1 errors compiling module, stopping
Fatal: (1018) Compilation aborted
Error: /Users/yd/Lazarus/v1.8.2n/fpc/bin/aarch64-darwin/ppca64 returned an error exitcode
--- End quote ---

I installed curl using brew. I found that libcurl exists under: /opt/homebrew/Cellar/curl/7.76.1/lib
below is content of this dir:


--- Quote ---┌<─ /opt/homebrew/Cellar/curl/7.76.1/lib ────────────────────────────────────────────.[^]>┐
│.n                              Name                                │ Size  │Modify time │
│/..                                                                 │UP--DIR│May  6 04:59│
│/pkgconfig                                                          │     96│May  6 04:59│
│ libcurl.4.dylib                                                    │ 596528│May  6 04:59│
│ libcurl.a                                                          │ 955824│Apr 14 08:58│
│@libcurl.dylib                                                      │     15│Apr 14 08:58│

--- End quote ---


question - how to make it to compile?
I can compile it on Windows & Linux.

Jonas Maebe:
Have you added that directory to the linker's library search path? (-Fl/opt/homebrew/Cellar/curl/7.76.1/lib) That directory is not a default directory in which the linker looks for libraries.

ydd:

--- Quote from: Jonas Maebe on May 06, 2021, 08:21:24 pm ---Have you added that directory to the linker's library search path? (-Fl/opt/homebrew/Cellar/curl/7.76.1/lib)
--- End quote ---

configured as you advised - same error

Jonas Maebe:
Looking at the source of that unit, it's missing a {$linklib curl} directive. I wonder why it was enabled for Darwin, since it was obviously never tested there.

(You can add that line to your program, it doesn't have to be in the unit itself)

ydd:

--- Quote from: Jonas Maebe on May 06, 2021, 09:47:20 pm ---Looking at the source of that unit, it's missing a {$linklib curl} directive. I wonder why it was enabled for Darwin, since it was obviously never tested there.
(You can add that line to your program, it doesn't have to be in the unit itself)

--- End quote ---

added, got big number of other errors - see attached file

Navigation

[0] Message Index

[#] Next page

Go to full version