odin1314 / yara-project

Automatically exported from code.google.com/p/yara-project
Apache License 2.0
0 stars 0 forks source link

Unable to configure yara 1.6 or HEAD on OpenBSD i386 #63

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

Problems are encountered at various stages of build process with a couple of 
workarounds possible:

1. Run ./configure from top level of source tree

What is the expected output? What do you see instead?

Expect configure script to find libpcre or libre2 in /usr/local/lib. Configure 
fails with:

checking for main in -lpcre... no
configure: error: please install PCRE library

Found in config.log:

configure:3835: checking for main in -lpcre
configure:3864: gcc -o conftest -g -O2   conftest.c -lpcre   >&5
/usr/bin/ld: cannot find -lpcre
collect2: ld returned 1 exit status

Similar behavior occurs with re2 library. It is not found by configure script 
at /usr/local/lib when installed there.

What version of the product are you using? On what operating system?

OpenBSD 5.1 i386
yara-1.6
yara-current (tip, HEAD from 2012/9/3)
pcre-8.21
re2 (current from 2012/9/3)

Please provide any additional information below.

Libraries are available and visible in the runtime linker cache:

$ ldconfig -r |grep pcre
        163:-lpcre.2.5 => /usr/local/lib/libpcre.so.2.5
        170:-lpcrecpp.3.3 => /usr/local/lib/libpcrecpp.so.3.3
        173:-lpcreposix.1.5 => /usr/local/lib/libpcreposix.so.1.5
        329:-lpcre++.1.0 => /usr/local/lib/libpcre++.so.1.0

...but are not found when running ./configure. 

The following invocation works:

CPPFLAGS="-I /usr/local/include" LDFLAGS="-L /usr/local/lib" ./configure

Is it possible to adjust sources to cause /usr/local/{include,lib} to be 
searched by the build scripts?

Original issue reported on code.google.com by phatbuck...@gmail.com on 4 Sep 2012 at 8:51

GoogleCodeExporter commented 9 years ago
This is not a defect in Yara, but rather user error in your OS's package 
management.

I'm not sure if this is the same under OpenBSD, but in Ubuntu, you must also 
install the "libpcre3-dev" package in addition to the libraries.  This contains 
the header files that the configure script is looking for to verify if the 
libraries are installed.  In this case, it is looking for /usr/include/pcre.h 
which is part of the libpcre3-dev package not the main libpcre3 package (in 
Ubuntu).

Things might be slightly different in OpenBSD.  You may need to make sure that 
some setting is made in the port to make sure that it installs header files in 
/usr/include or wherever it keeps those header files.

Original comment by rsimmo...@gmail.com on 1 May 2013 at 5:33

GoogleCodeExporter commented 9 years ago
You mean this header file?

$ pkg_info -L pcre |grep 'pcre\.h$'
/usr/local/include/pcre.h

$ ls -l /usr/local/include/pcre.h                                            
-r--r--r--  1 root  bin  23188 Aug  3  2012 /usr/local/include/pcre.h

Seems kosher.

OpenBSD does not separate development parts from main parts in their packages. 
It tends to avoid the issues referred to in comment #1.

Original comment by phatbuck...@gmail.com on 2 May 2013 at 4:47

GoogleCodeExporter commented 9 years ago
Trying again using yara 1.7 on OpenBSD 5.2 i386.

$ ./configure
...
checking whether the g++ linker (/usr/bin/ld) supports shared libraries... yes
checking dynamic linker characteristics... openbsd5.2 ld.so
checking how to hardcode library paths into programs... immediate
checking dependency style of g++... gcc3
checking for main in -lpcre... no
configure: error: please install PCRE library

(Exits status 1).

$ ./configure --with-re2
...
checking whether the g++ linker (/usr/bin/ld) supports shared libraries... yes
checking dynamic linker characteristics... openbsd5.2 ld.so
checking how to hardcode library paths into programs... immediate
checking dependency style of g++... gcc3
checking for main in -lre2... no
configure: error: please install RE2 library

(Exits status 1).

$ ldconfig -r |grep re2                                                         

        231:-lre2.0.0 => /usr/local/lib/libre2.so.0.0.0

$ ls -l /usr/local/include/re2/                                                 

total 128
-rw-r--r--  1 root  wheel   3573 May  1 22:48 filtered_re2.h
-rw-r--r--  1 root  wheel  33985 May  1 22:48 re2.h
-rw-r--r--  1 root  wheel   1688 May  1 22:48 set.h
-rw-r--r--  1 root  wheel   5851 May  1 22:48 stringpiece.h
-rw-r--r--  1 root  wheel  16675 May  1 22:48 variadic_function.h

$ CPPFLAGS="-I /usr/local/include/re2" LDFLAGS="-L /usr/local/lib" ./configure 
--with-re2
...
checking if g++ supports -c -o file.o... (cached) yes
checking whether the g++ linker (/usr/bin/ld) supports shared libraries... yes
checking dynamic linker characteristics... openbsd5.2 ld.so
checking how to hardcode library paths into programs... immediate
checking dependency style of g++... gcc3
checking for main in -lre2... no
configure: error: please install RE2 library

(Exits status 1).

In config.log:

...
configure:15466: checking for main in -lre2
configure:15485: g++ -o conftest -g -O2 -I/usr/local/include/re2 
-L/usr/local/lib conftest.cpp -lre2   >&5
/usr/local/lib/libre2.so: warning: sprintf() is often misused, please use 
snprintf()
/usr/local/lib/libre2.so: undefined reference to `pthread_rwlock_rdlock'
/usr/local/lib/libre2.so: undefined reference to `pthread_rwlock_init'
/usr/local/lib/libre2.so: undefined reference to `pthread_rwlock_destroy'
/usr/local/lib/libre2.so: undefined reference to `pthread_rwlock_unlock'
/usr/local/lib/libre2.so: undefined reference to `pthread_rwlock_wrlock'
/usr/local/lib/libre2.so: undefined reference to `pthread_mutex_unlock'
/usr/local/lib/libre2.so: undefined reference to `pthread_mutex_lock'
collect2: ld returned 1 exit status
configure:15485: $? = 1

$ file /usr/local/lib/libre2.so.0.0.0                                           

/usr/local/lib/libre2.so.0.0.0: ELF 32-bit LSB shared object, Intel 80386, 
version 1, for OpenBSD, dynamically linked, not stripped

$ objdump -t /usr/local/lib/libre2.so.0.0.0 |grep -i pthread
00000000         *UND*  00000000 pthread_rwlock_rdlock
00000000         *UND*  00000000 pthread_rwlock_init
00000000  w      *UND*  00000000 pthread_cancel
00000000         *UND*  00000000 pthread_rwlock_destroy
00000000         *UND*  00000000 pthread_rwlock_unlock
00000000         *UND*  00000000 pthread_rwlock_wrlock
00000000         *UND*  00000000 pthread_mutex_unlock
00000000         *UND*  00000000 pthread_mutex_lock

Issue with RE2 library linking against pthread? I don't really understand from 
here.

Original comment by phatbuck...@gmail.com on 2 May 2013 at 8:42

GoogleCodeExporter commented 9 years ago
Had the same issue then ran this command:
 sudo apt-get install libpcre3 libpcre3-dev

Must have been missing a lib.  

Ran ./configure and it worked.

Original comment by rkeq0...@gmail.com on 27 Jun 2013 at 4:59

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
For some reason the below flags are not set correctly. Export before calling 
configure should work.
$> export LDFLAGS="-L/usr/local/lib"
$> export CFLAGS=-I/usr/local/include
$> ./configure

Original comment by info.var...@gmail.com on 8 Oct 2013 at 9:59