Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compile fails with net-snmp-5.8 and openssl-1.1.1d #25

Open
jeffreyscottgraham opened this issue Oct 9, 2019 · 16 comments
Open

compile fails with net-snmp-5.8 and openssl-1.1.1d #25

jeffreyscottgraham opened this issue Oct 9, 2019 · 16 comments

Comments

@jeffreyscottgraham
Copy link

snmp_openssl.c: In function 'DH_get0_pqg':
snmp_openssl.c:31:15: error: dereferencing pointer to incomplete type 'DH' {aka 'const struct dh_st'}
31 | *p = dh->p;
| ^~
snmp_openssl.c: In function 'DH_set0_pqg':
snmp_openssl.c:57:11: error: dereferencing pointer to incomplete type 'DH' {aka 'struct dh_st'}
57 | if ((dh->p == NULL && p == NULL)
| ^~
make[1]: *** [Makefile:100: snmp_openssl.lo] Error 1

@bvanassche
Copy link
Contributor

Did you build openssl from source or did you install a software package that was provided by your Linux distributor? In the latter case, which Linux distribution are you using?

@jeffreyscottgraham
Copy link
Author

From source

@bvanassche
Copy link
Contributor

I will have a look but it could take a few days before I have the time to take a look.

@bvanassche
Copy link
Contributor

Did you perhaps use the official v5.8 release? Please retest with the latest version of the v5.8 branch (https://github.com/net-snmp/net-snmp/tree/V5-8-patches). This issue has been solved a while ago.

@hanhanlee
Copy link

hanhanlee commented Dec 10, 2019

Hi bvanassche,

I had this issue too, I downloaded netsnmp5.8 from here: https://github.com/net-snmp/net-snmp/tree/V5-8-patches and compiled it with openssl-1.1.1d.

However, I met some errors when I "make":

snmp_openssl.c: In function 'DH_get0_pqg':
snmp_openssl.c:31:15: error: dereferencing pointer to incomplete type
*p = dh->p;
^
snmp_openssl.c:33:15: error: dereferencing pointer to incomplete type
*q = dh->q;
^
snmp_openssl.c:35:15: error: dereferencing pointer to incomplete type
*g = dh->g;
^
snmp_openssl.c: In function 'DH_get0_key':
snmp_openssl.c:44:21: error: dereferencing pointer to incomplete type
*pub_key = dh->pub_key;
^
snmp_openssl.c:46:22: error: dereferencing pointer to incomplete type
*priv_key = dh->priv_key;
^
snmp_openssl.c: In function 'DH_set0_pqg':
snmp_openssl.c:57:11: error: dereferencing pointer to incomplete type
if ((dh->p == NULL && p == NULL)
^
snmp_openssl.c:58:14: error: dereferencing pointer to incomplete type
|| (dh->g == NULL && g == NULL))
^
snmp_openssl.c:62:18: error: dereferencing pointer to incomplete type
BN_free(dh->p);
^
snmp_openssl.c:63:10: error: dereferencing pointer to incomplete type
dh->p = p;
^
snmp_openssl.c:66:18: error: dereferencing pointer to incomplete type
BN_free(dh->q);
^
snmp_openssl.c:67:10: error: dereferencing pointer to incomplete type
dh->q = q;
^
snmp_openssl.c:70:18: error: dereferencing pointer to incomplete type
BN_free(dh->g);
^
snmp_openssl.c:71:10: error: dereferencing pointer to incomplete type
dh->g = g;
^
snmp_openssl.c:75:10: error: dereferencing pointer to incomplete type
dh->length = BN_num_bits(q);

Could you please have a look at it?

Many thanks!

@bvanassche
Copy link
Contributor

@hanhanlee, please double check which version was downloaded. It seems like version v5.8 was downloaded instead of the latest version of the V5-8-patches branch. One way to download the latest version of that branch is by following this link: https://codeload.github.com/net-snmp/net-snmp/zip/V5-8-patches.

@hanhanlee
Copy link

@bvanassche , After re-downloading source code from your link, it works fine!
Thanks a lot!!

@phuong-dut-es
Copy link

still having the same error when download bvannassche patch

@bvanassche
Copy link
Contributor

@phuong-dut-es, please provide more information. Which version of openssl are you using and which error message is displayed?

@jeffreyscottgraham
Copy link
Author

@bvanassche just fix it already. we cant all be dummies

@nonedark2008
Copy link

I had the same problem while building static net-snmp 5.9.1 with static openssl 1.1.1l (built manually from source). Configuration script incorrectly detects functions like DH_get0_pqg because of missing dependencies, -lpthread and -ldl in my case.
Part of my config.log:

configure:25263: result: no
configure:25263: checking for DH_get0_pqg
configure:25263: gcc -o conftest -DNETSNMP_ENABLE_IPV6 -fno-strict-aliasing -DNETSNMP_REMOVE_U64 -m64 -O3 -s -fPIC -Ulinux -Dlinux=linux -I/home/stanislav/.conan/data/openssl/1.1.1l/_/_/package/3a5f72c8cd50641b8efa6ed13e6914c6ced2747c/include -I/home/stanislav/.conan/data/openssl/1.1.1l/_/_/package/3a5f72c8cd50641b8efa6ed13e6914c6ced2747c/include -DNDEBUG -L/home/stanislav/.conan/data/openssl/1.1.1l/_/_/package/3a5f72c8cd50641b8efa6ed13e6914c6ced2747c/lib -m64 -L/home/stanislav/.conan/data/openssl/1.1.1l/_/_/package/3a5f72c8cd50641b8efa6ed13e6914c6ced2747c/lib conftest.c -lcrypto >&5
/home/stanislav/.conan/data/openssl/1.1.1l/_/_/package/3a5f72c8cd50641b8efa6ed13e6914c6ced2747c/lib/libcrypto.a(threads_pthread.o): In function `CRYPTO_THREAD_lock_new':
threads_pthread.c:(.text+0x45): undefined reference to `pthread_rwlock_init'
/home/stanislav/.conan/data/openssl/1.1.1l/_/_/package/3a5f72c8cd50641b8efa6ed13e6914c6ced2747c/lib/libcrypto.a(threads_pthread.o): In function `CRYPTO_THREAD_read_lock':
threads_pthread.c:(.text+0x85): undefined reference to `pthread_rwlock_rdlock'
/home/stanislav/.conan/data/openssl/1.1.1l/_/_/package/3a5f72c8cd50641b8efa6ed13e6914c6ced2747c/lib/libcrypto.a(threads_pthread.o): In function `CRYPTO_THREAD_write_lock':
threads_pthread.c:(.text+0xa5): undefined reference to `pthread_rwlock_wrlock'
/home/stanislav/.conan/data/openssl/1.1.1l/_/_/package/3a5f72c8cd50641b8efa6ed13e6914c6ced2747c/lib/libcrypto.a(threads_pthread.o): In function `CRYPTO_THREAD_unlock':
threads_pthread.c:(.text+0xc5): undefined reference to `pthread_rwlock_unlock'
/home/stanislav/.conan/data/openssl/1.1.1l/_/_/package/3a5f72c8cd50641b8efa6ed13e6914c6ced2747c/lib/libcrypto.a(threads_pthread.o): In function `CRYPTO_THREAD_lock_free':
threads_pthread.c:(.text+0xea): undefined reference to `pthread_rwlock_destroy'
/home/stanislav/.conan/data/openssl/1.1.1l/_/_/package/3a5f72c8cd50641b8efa6ed13e6914c6ced2747c/lib/libcrypto.a(threads_pthread.o): In function `CRYPTO_THREAD_run_once':
threads_pthread.c:(.text+0x115): undefined reference to `pthread_once'
/home/stanislav/.conan/data/openssl/1.1.1l/_/_/package/3a5f72c8cd50641b8efa6ed13e6914c6ced2747c/lib/libcrypto.a(threads_pthread.o): In function `CRYPTO_THREAD_init_local':
threads_pthread.c:(.text+0x135): undefined reference to `pthread_key_create'
/home/stanislav/.conan/data/openssl/1.1.1l/_/_/package/3a5f72c8cd50641b8efa6ed13e6914c6ced2747c/lib/libcrypto.a(threads_pthread.o): In function `CRYPTO_THREAD_set_local':
threads_pthread.c:(.text+0x167): undefined reference to `pthread_setspecific'
/home/stanislav/.conan/data/openssl/1.1.1l/_/_/package/3a5f72c8cd50641b8efa6ed13e6914c6ced2747c/lib/libcrypto.a(threads_pthread.o): In function `CRYPTO_THREAD_cleanup_local':
threads_pthread.c:(.text+0x187): undefined reference to `pthread_key_delete'
/home/stanislav/.conan/data/openssl/1.1.1l/_/_/package/3a5f72c8cd50641b8efa6ed13e6914c6ced2747c/lib/libcrypto.a(threads_pthread.o): In function `openssl_init_fork_handlers':
threads_pthread.c:(.text+0x1e3): undefined reference to `pthread_once'
/home/stanislav/.conan/data/openssl/1.1.1l/_/_/package/3a5f72c8cd50641b8efa6ed13e6914c6ced2747c/lib/libcrypto.a(threads_pthread.o): In function `fork_once_func':
threads_pthread.c:(.text+0x16): undefined reference to `pthread_atfork'
/home/stanislav/.conan/data/openssl/1.1.1l/_/_/package/3a5f72c8cd50641b8efa6ed13e6914c6ced2747c/lib/libcrypto.a(threads_pthread.o): In function `CRYPTO_THREAD_get_local':
threads_pthread.c:(.text+0x153): undefined reference to `pthread_getspecific'
/home/stanislav/.conan/data/openssl/1.1.1l/_/_/package/3a5f72c8cd50641b8efa6ed13e6914c6ced2747c/lib/libcrypto.a(dso_dlfcn.o): In function `dlfcn_globallookup':
dso_dlfcn.c:(.text+0x11): undefined reference to `dlopen'
dso_dlfcn.c:(.text+0x24): undefined reference to `dlsym'
dso_dlfcn.c:(.text+0x2f): undefined reference to `dlclose'

I bypassed this error by editing the configure script. There are lines LIBS="$LIBCRYPTO" and LIBS="-lssl". I changed them into LIBS="$LIBCRYPTO $LIBS" and LIBS="-lssl $LIBS". And before running the script I set an environment variable LIBS='-pthread -ldl'.

bvanassche added a commit that referenced this issue Dec 26, 2021
Which libraries must be linked in addition to the ssl library depends on the
configuration of OpenSSL and on the platform. Hence use pkg-config to detect
these libraries if pkg-config is available. See also "compile fails with
net-snmp-5.8 and openssl-1.1.1d"
(#25).
@bvanassche
Copy link
Contributor

Please install pkg-config if it has not yet been installed and retest with the latest version of the v5.9 branch or the master branch. See also commit 8c3a094.

@nonedark2008
Copy link

@bvanassche, thank you for the fix. Just tested with the latest v5.9 branch and everything works like a charm!

@jinchaox7260
Copy link

@bvanassche

I encountered the same issue when cross compiling Net snmp 5.9.3 on the Windows platform and adding the header file generated by openssl 3.1.0, but it was not a problem when compiling on Ubuntu. Ubuntu has already installed libssl dev, and I'm not sure if it's related to this?

@bvanassche
Copy link
Contributor

@jinchaox7260 Did I understand correctly that you are running a cross-compiler on Windows? I haven't tried this before.

@jinchaox7260
Copy link

@bvanassche
Thank you feed back!
After adding ssl and crypto dynamic libraries, the problem was resolved

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants