[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Undefined symbol
Answer to the question, the error from clang without defining unistd.h in platform.h was:
In file included from zxlibdec.c:24:
./platform.h:179:5: error: conflicting types for 'lseek'
int lseek(int fd, int offset, int whence);
/usr/include/sys/types.h:376:8: note: previous declaration is here
off_t lseek(int, off_t, int);
1 error generated.
clang -o zxlibdec.o -c zxlibdec.c -g -fPIC -fno-strict-aliasing -Wl,--export-all-symbols -Wl,--export-dynamic -fmessage-length=0 -Wall -Wno-parentheses -Wno-unused-label -Wno-unknown-pragmas -Wno-char-subscripts -ffunction-sections -fdata-sections -DUSE_ZXID -DUSE_SSL -DUSE_CURL -DUSE_OPENSSL -D_REENTRANT -DDEBUG -DMUTEX_DEBUG=1 -DFREEBSD -DUSE_PTHREAD -lpthread -I. -I/usr/local/httpd/src/zxid-1.22 -I/usr/local/include
Makefile:699: recipe for target 'zxlibdec.o' failed
gmake: *** [zxlibdec.o] Error 1
And the port can be found from for example URL: http://www.freshports.org/security/zxid/. In the ports tree it is in /usr/ports/security/zxid . From here, Makefile has changes without the Apache module and the patches can be found from files directory:
[/usr/ports/security/zxid]$ ls files
patch-pkcs12.c patch-platform.h patch-zx.h
I'm not sure if I have used the changes in all of these.
With best regards,
> On Saturday, December 5, 2015 6:28 PM, "sampo@xxxxxxxx" <sampo@xxxxxxxx> wrote:
> > Jouni Laakso <jounijl@xxxxxxxxxxx> said:
>> FreeBSD has moved on to using clang instead of gcc at it's version 10.
> A port of ZXID is available without the module to Apache httpd, mod_auth_saml.so
>> After compiling the module and trying to start httpd, an error appears:
>> httpd: Syntax error on line 73 of /usr/local/etc/apache24/httpd.conf:
> Cannot load
>> libexec/apache24/mod_auth_saml.so into server:
>> /usr/local/libexec/apache24/mod_auth_saml.so: Undefined symbol
>> After searching with nm and from files was found that
> "zx_attr2tok" is defined in "./c/zx-data.h", implemented in
> "./c/zx-attrs.c" and used in "./zxlibdec.c". I tried to add
> a line to
>> zx-attrs.c as follows:
>> $ diff c/zx-attrs.c ../../zxid-1.22/c/zx-attrs.c
>> > #include "c/zx-data.h"
>> < struct zx_at_tok *
>> < zx_attr2tok (str, len)
>> > struct zx_at_tok * zx_attr2tok (str, len)
>> And after adding, the module loaded correctly to httpd.
>> Question: Should this include be added to the zx-attrs.c permanently ?
> Everything in the c/ subdirectory is autogenerated prior to the distribution
> tar ball being rolled.
> Not sure why adding the include to the .c file that actually defines
> the function would make any difference. My understanding of C language
> is that all functions are exported by default except if they have static
> In any case, for short term your solution is ok, but for next release
> I will change the code generation system to add that include into
> the generated files.
>> Another problem is using the --export-all-symbols. It does not exist in gcc
> or in clang.
> It does exist in earlier versions of gcc. A more modern incantation
> would be -Wl,--export-dynamic
> If you have FreeBSD specific Makefile changes, locate the section
> that starts ifeq ($(TARGET),freebsd). You may also consider creating
> a new version specific FreeBSD section. In that section you can add to
> or override compile flags. For local hacks, consider using localconf.mk
>> I havent yet tried to use the module. Just as soon I still remember these
> commands and header files, I just send the email. Apache 2.4 maby can be used,
> Either Apache httpd 2.2 or 2.4 can be used, but the mod_auth_saml module
> has to be compiled for the specific version. Using module compiled for 2.4
> will crash on 2.2 and vice versa. This is due to changes in Apache internal
> APIs (deliberate break with backwards compatibility decided by Apache team).
> I think the documentation is mainly from 2.2 so the example httpd.conf
> syntax may not work on 2.4, but the ZXIDConf directive continues to behave
> the same.
>> am I correct? It would be nice if after TAS3 project, the ZXID would
>> still be maintained. Is it possible to make a prognosis about it?
> ZXID will be maintained by me for foreseeable future (at least next 5-10
>> The environment description follows. If includes are difficult with swig
> for example, Linux and FreeBSD have defines like the following to recognize the
> operating system. I haven't read enough about the package to recommend
>> With best regards,
>> Jouni L.
>> Operating system is: FreeBSD 10.2-RELEASE #9
>> I made an environment like this:
>> zxid@ ~/src/zxid-1.22]$ ld --version
>> GNU ld 2.17.50 [FreeBSD] 2007-07-03
>> [root@ ]# pkg install gcc # not necessary
>> [root@ ]# pkg install gmake # needed
>> [root@ ]# pkg install swig # needed
> I do not believe you need swig normally. I distribute in the tarball
> the files generated by swig, gperf, and xsd2sg.pl. Only someone
> wanting to perform full rebuild from scratch would need those tools.
>> alias swig=/usr/local/bin/swig2.0
>> alias make=/usr/local/bin/gmake
>> CC=" clang "; export C
>> and added missing headerlines:
>> [zxid@ ~/src/zxid-1.22]$ diff platform.h platform.h_orig
> In future please send unified context diffs (diff -u).
>> < #ifdef __FreeBSD__
>> < #include <unistd.h>
>> < #endif
> Which symbol caused this include to be needed? You may have observed a
> comment in platform.h where I justify why I try to avoid that include.
>> [zxid@ ~/src/zxid-1.22]$ diff zxidconf.c zxidconf.c_orig
>> < #ifndef __FreeBSD__
>> < #else
>> < #include <stdlib.h>
>> < #endif
> The inclusion of <stdlib.h> can be done without __FreeBSD__ check as
> that library is available on all supported platforms including Windows (I
> think its existence is madatory in K&R). In fact I see it included
> unconditionally (for all platforms) in platform.h:9
> Thanks for the patches.
>> Makefile had these changes (some of them useless):
>> [zxid@ ~/src/tmp/zxid-1.22]$ diff Makefile ~/src/zxid-1.22/Makefile
>> < APACHE_INC ?= -I/usr/include/apache2
>> < APR_INC ?= -I/usr/include/apr-1.0
>> < APACHE_MODULES ?= /usr/lib/apache2/modules
>> > #APACHE_INC ?= -I/usr/include/apache2
>> > APACHE_INC ?= -I/usr/local/include/apache24
>> > APR_INC ?= -I/usr/local/include/apr-1
>> > APACHE_MODULES ?= /usr/local/libexec/apache24
>> < CINC+=-I. -I$(TOP)
>> > CINC+=-I. -I$(TOP) -I/usr/local/include
>> < LIBS+= -lcurl -lssl -lcrypto -lz $(POSTLIBS)
>> > LIBS+= -lcurl -lssl -lcrypto -lz $(POSTLIBS) -lc -L/usr/local/lib
>> < SHARED_FLAGS=-shared -Wl,--export-dynamic -Wl,--whole-archive
>> > SHARED_FLAGS=-shared -Wl,--export-dynamic -Wl,--whole-archive
>> < CDEF+= -DUSE_PTHREAD -pthread
>> > #CDEF+= -DUSE_PTHREAD -pthread
>> > CDEF+= -DUSE_PTHREAD -lpthread
>> Commands used was these:
>> make TARGET=freebsd apachezxid
>> make TARGET=freebsd apachezxid_install
>> make dir