g++ command line/shared libraries -- some questions

I am compiling a program called CCExtractor in Terminal on a Mac. The program is downloaded as source code, and the developer includes this ...

 
g++ -Dfopen64=fopen -Dopen64=open -Dlseek64=lseek -I../src/gpacmp4 -I ../src/libpng -I ../src/zlib -o ccextractor $(find ../src/ -name '*.cpp') $(find ../src/ -name '*.c')


... as a g++ command line for compiling it. It doesn't work, giving me an "illegal variable name" error. I can intuit what the "$(find ... )" specifications are supposed to mean, and if I manually do the equivalent "find" commands and replace the "$(find ... )" specifications with the results of the manual "find" commands, the g++ command works and produces a good executable.

My first question is, is "$(find ... )" a meaningful specification in Mac g++ commands, and if so why doesn't it work as originally specified? (BTW, before using the g++ command, I do a "cd" (change directory) to the proper directory so that things like

 
find ../src/ -name '*.cpp'


work as intended.)

If "$(find ... )" is not a proper way to locate all the intended source files, can anyone tell me why the software's author thought it was.

BTW, I am admittedly not well versed in using Unix or g++ ... in Terminal on a Mac or on any other machine. Please forgive me if I am asking dumb questions.

Another possibly dumb question is, how can I tell if my CCExtractor executable uses any dynamic or shared libraries? I am in touch with someone who wants to know, as he might want to distribute my CCExtractor executable to other Mac users as a useful tool to accompany his "kmttg" software. If the executable uses shared libraries, it might break if those libraries aren't present. How can I tell if this might become a problem?

Thanks for any help anyone can provide.
It looks like variable specifier for make command. I do not familiar with MAC developer tools but it looks like it have make program you can get with Xcode

EDIT: and it looks like it still incorrect: you need to use $(shell find ...) to invoke shell command.
Last edited on
OK, I tried changing both specifications to "$(shell find ... ), but I still get "Illegal variable name" ...
about $(command)
http://www.gnu.org/software/bash/manual/bashref.html#Command-Substitution
if Mac does another thing with $( ) you may try backsticks
`command`

Edit: if you intent to use it in a makefile, then you need to invoke a shell
http://blog.melski.net/2010/11/15/shell-commands-in-gnu-make/#dollar_shell


> If the executable uses shared libraries, it might break if those libraries aren't present.
> How can I tell if this might become a problem?
http://man7.org/linux/man-pages/man1/ldd.1.html
Last edited on
That was a big help! Thanks.

I figured out from that what the basic problem was. I was using a tcsh shell and the g++ command needs a bash shell.

Also, I had to use

otool -L

instead of

ldd

which is not supported on a Mac. It showed me that my executable uses two dynamic libraries associated with c++.
Topic archived. No new replies allowed.