Comments (7)
Comment for anyone looks up ...
Came across the 'same' thing on Windows: static link pcre.
-static
doesn't help.
Try add -DPCRE_STATIC
to your CFLAGS
. It is a trick of PCRE
;p
Read pcre.h
, you will see:
#if defined(_WIN32) && !defined(PCRE_STATIC)
# ifndef PCRE_EXP_DECL
# define PCRE_EXP_DECL extern __declspec(dllimport)
# endif
# ifdef __cplusplus
# ifndef PCRECPP_EXP_DECL
# define PCRECPP_EXP_DECL extern __declspec(dllimport)
# endif
# ifndef PCRECPP_EXP_DEFN
# define PCRECPP_EXP_DEFN __declspec(dllimport)
# endif
# endif
#endif
/* By default, we use the standard "extern" declarations. */
#ifndef PCRE_EXP_DECL
# ifdef __cplusplus
# define PCRE_EXP_DECL extern "C"
# else
# define PCRE_EXP_DECL extern
# endif
#endif
from the_silver_searcher.
Assuming you have a libpcre.a somewhere in your LDPATH, shouldn't CFLAGS="-static" ./build.sh
do the trick? (Be sure to make clean before this.)
from the_silver_searcher.
CFLAGS="-static" ./build.sh
on OS X yields the following error:
checking for gcc... gcc
checking whether the C compiler works... no
configure: error: in `/Users/nathansobo/code/the_silver_searcher':
configure: error: C compiler cannot create executables
See `config.log' for more details
The relevant section of config.log
seems to be:
...
configure:2308: checking whether the C compiler works
configure:2330: gcc -static conftest.c >&5
ld: library not found for -lcrt0.o
collect2: ld returned 1 exit status
...
This seems to be due to the fact that no static version of crt0.o
is provided. From man gcc
on OS X:
...
-static
On systems that support dynamic linking, this prevents linking with the shared libraries. On other systems, this
option has no effect.
This option will not work on Mac OS X unless all libraries (including libgcc.a) have also been compiled with -static.
Since neither a static version of libSystem.dylib nor crt0.o are provided, this option is not useful to most people.
...
So it seems as if I can't flag the entire executable to be static. I'd have to statically link only against libpcre.a
, which is available in the same directory as the dynamic library so presumably on my link path.
Thanks Geoff for taking the time to respond.
from the_silver_searcher.
I assumed you were on Linux. You've reached the extent of my knowledge on this subject.
I think if you just want to link to .a files, you can add them to the gcc command. So instead of
gcc -g -O2 -Wall -Wextra -std=c89 -D_GNU_SOURCE -o ag src/ignore.o src/log.o src/options.o src/print.o src/search.o src/util.o src/main.o -lpcre
it would be
gcc -g -O2 -Wall -Wextra -std=c89 -D_GNU_SOURCE -o ag src/ignore.o src/log.o src/options.o src/print.o src/search.o src/util.o src/main.o /path/to/libpcre.a
(Scroll all the way to the end of that line to see the difference. -lpcre
was replaced with /path/to/libpcre.a
from the_silver_searcher.
This isn't a bug in Ag and I can't help anymore, so I'm closing this issue.
from the_silver_searcher.
Okay... I figured out. Here's my solution:
PCRE_LIBS="/usr/local/Cellar/pcre/8.30/lib/libpcre.a" ./build.sh
It looks like the binary is statically linked to PCRE, based on this:
otool -L ./ag
./ag:
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 159.1.0)
And I brew uninstall
ed PCRE and the binary still worked. Thanks for your time!
from the_silver_searcher.
Cool beans.
from the_silver_searcher.
Related Issues (20)
- Anyone want to help with a friendly fork of this project? HOT 6
- --make file type...
- Travis CI badge is broken
- Compilation stoped on qualifier from pointer target type [-Wcast-qual] HOT 1
- "bus error" on Mac OS with specific test file and regex HOT 1
- ag not finding accent letters in case insensitive search explicitly with -i option
- If the file doesn't exist, skip search instead of throwing errors
- wrong output on osx default terminal
- Confused about flag `--print-long-lines`: long lines seem to be printed by default? But can't turn that behavior *off* or modify it? (like `--print-long-lines=false` or `--print-long-lines=200` or something?)
- 2.2.0: test suite uses cram which is no longer maintained
- Add per-directory .gitignore support
- ignore patterns should not directory below their source file
- ag incorrectly parses [.][^.]*$
- feat: include OSC8 escape codes in output
- memory leak in function 'parse_options' HOT 1
- ag does not work on tmpfs/cgroup filesystem
- Entries in .gitignore are applied to the wrong base directory
- Bash completion script is broken with bash-completion v2.12.0 HOT 1
- Missing `S_ISSOCK` for stdin check HOT 1
- Depends on deprecated pcre library
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from the_silver_searcher.