I've had problems linking, as there is a discrepancy between what the bash command returns for the path for an EXTERN.h and what exists on this machine.
We also have some shell evaluations. The first expression evaluates and works just fine:
$ (perl -MConfig -e 'print $Config{cc}')
x86_64-linux-gnu-gcc$
The second one seems to work; the problem is that I don't have an EXTERN.h exactly there:
$ (perl -MExtUtils::Embed -e ccopts -e ldopts)
-Wl,-E -fstack-protector-strong -L/usr/local/lib -L/usr/lib/x86_64-l
+inux-gnu/perl/5.26/CORE -lperl -ldl -lm -lpthread -lc -lcrypt
-D_REENTRANT -D_GNU_SOURCE -DDEBIAN -fwrapv -fno-strict-aliasing -pip
+e -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I
+/usr/lib/x86_64-linux-gnu/perl/5.26/CORE $
One thing I figured out is that it has a newline in it. The bigger problem is that I do not have a perl.h nor an EXTERN.h in this location.
Where do I have one?
$ locate EXTERN.h
/usr/lib/x86_64-linux-gnu/perl/5.26.1/CORE/EXTERN.h
$
5.26 is just a link:
$ pwd
/usr/lib/x86_64-linux-gnu/perl
$ ls -l 5.26*
lrwxrwxrwx 1 root root 6 Jul 18 2018 5.26 -> 5.26.1
I read up a bit with ExtUtils::Embed, gave this a look-see:
perl -MExtUtils::Embed -e perl_inc
-I/usr/lib/x86_64-linux-gnu/perl/5.26/CORE
Let's try re-ordering:
x86_64-linux-gnu-gcc perl_embed_argv_signal.c -Wl,-E -fstack-protector-strong -I/usr/lib/x86_64-linux-gnu/perl/5.26.1/CORE -L/usr/local/lib -L/usr/lib/x86_64-linux-gnu/perl/5.26.1/CORE -lperl -ldl -lm -lpthread -lc -lcrypt -D_REENTRANT -D_GNU_SOURCE -DDEBIAN -fwrapv -fno-strict-aliasing -pipe -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -o embedex
A different linking problem:
/usr/bin/ld: cannot find -lperl
collect2: error: ld returned 1 exit status
Then from all those years in comp.lang.c, I remember that the thing you do is s/l/lib/, so:
Update the package index:
# sudo apt-get update
Install libperl-dev deb package:
# sudo apt-get install libperl-dev
Same command with necessary library:
$ x86_64-linux-gnu-gcc perl_embed_argv_signal.c -Wl,-E -fstack-protec
+tor-strong -I/usr/lib/x86_64-linux-gnu/perl/5.26.1/CORE -L/usr/local
+/lib -L/usr/lib/x86_64-linux-gnu/perl/5.26.1/CORE -lperl -ldl -lm -l
+pthread -lc -lcrypt -D_REENTRANT -D_GNU_SOURCE -DDEBIAN -fwrapv -fno-
+strict-aliasing -pipe -I/usr/local/include -D_LARGEFILE_SOURCE -D_FIL
+E_OFFSET_BITS=64 -o embedex
$ ls
1.84.txt 2.analyse_text.pl embedex
1.analyse_text.pl 2.bliako.pl hs_ref_GRCh38.p12_chr20.fa
1.bliako.pl 2.bliako.txt hs_ref_GRCh38.p12_chr20.fa.3.
+state
1.bliako.txt 2.create.bash hs_ref_GRCh38.p12_chr20.fa.gz
1.c_calls_perl.c 3.bliako.txt Markov
1.em_perl.c 84-0.txt perl_embed_argv_signal.c
1.manifest 84.state 'Untitled Document 1'
1.predict.pl bliako1.pm 'Untitled Document 2'
$ ./embedex fruit flying dutchman
./embedex : perl_alloc()
./embedex : perl_construct()
./embedex : executing :
#$SIG{INT} = sub { print "Caught your ctrl-c and exiting!\n"; exit(0);
+ };
$SIG{INT} = sub { print "Caught your ctrl-c but ignoring it!\n" };
print "$0: ARGV:"; print ' '.$_ foreach(@ARGV); print "\n";
print "my pid $$\n";
print "now sleeping, and you ctrl-c me\n";
for(1..100){sleep(1);print"$_\n";}
-e: ARGV: fruit flying dutchman
my pid 21007
now sleeping, and you ctrl-c me
1
2
3
4
5
^CCaught your ctrl-c but ignoring it!
6
7
8
9
^CCaught your ctrl-c but ignoring it!
10
11
12
13
...
99
100
./embedex : done.
$
And now with ctrl-c commented out the other way:
$ x86_64-linux-gnu-gcc 2.perl_embed_argv_signal.c -Wl,-E -fstack-prot
+ector-strong -I/usr/lib/x86_64-linux-gnu/perl/5.26.1/CORE -L/usr/loc
+al/lib -L/usr/lib/x86_64-linux-gnu/perl/5.26.1/CORE -lperl -ldl -lm
+-lpthread -lc -lcrypt -D_REENTRANT -D_GNU_SOURCE -DDEBIAN -fwrapv -fn
+o-strict-aliasing -pipe -I/usr/local/include -D_LARGEFILE_SOURCE -D_F
+ILE_OFFSET_BITS=64 -o embedex2
$ ./embedex2 slithy toves wirr and wimbel
./embedex2 : perl_alloc()
./embedex2 : perl_construct()
./embedex2 : executing :
$SIG{INT} = sub { print "Caught your ctrl-c and exiting!\n"; exit(0);
+};
#$SIG{INT} = sub { print "Caught your ctrl-c but ignoring it!\n" };
print "$0: ARGV:"; print ' '.$_ foreach(@ARGV); print "\n";
print "my pid $$\n";
print "now sleeping, and you ctrl-c me\n";
for(1..15){sleep(1);print"$_\n";}
-e: ARGV: slithy toves wirr and wimbel
my pid 21094
now sleeping, and you ctrl-c me
1
2
3
4
5
^CCaught your ctrl-c and exiting!
$
I'm glad to finally see output.... |