Can anyone tell me how to initialize a SNMP agent in c using SNMP library?
The call to "init_agent()" is not working.
I read somewhere that "init_agent()" function should be used before "init_snmp()".
Here is what I am getting while compiling the code:
/tmp/ccEiSj2l.o: In function `main':
agent1.c:(.text+0x95): undefined reference to `init_agent'
collect2: ld returned 1 exit status
I have linked the compiler to snmp library using "-lsnmp".
Did you try passing required libraries to your compiler? Try passing output of the script net-snmp-config --libs . (Put back quotes surrounding that command).
I am used to using Net-SNMP for these things, and if you are attempting to create an agent with Net-SNMP, then you will need to link against the agent library (in addition to whatever other libraries you may be using):
-lnetsnmpagent
Related
I've been trying to get the regex.h library to work all day, but it's not working. (Here are my VS Code workspace configurations: https://github.com/EnderCommunity/Murmur/tree/main/.vscode - all the compiler info are here)
This is the file that I was trying to get the regex library to work with:
https://github.com/EnderCommunity/Murmur/blob/main/compiler/libraries/regex/reg.h
I tried to include the library normally, but it returns an error:
And I tried to include this library, but it returns some compiling errors:
> Executing task: C/C++: gcc.exe build active file <
Starting build...
"C:\Program Files\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64\bin\gcc.exe" -g C:\Users\adels\Desktop\EnderCommunity\Projects\Murmur\compiler\start.c -o C:\Users\adels\Desktop\EnderCommunity\Projects\Murmur\compiler\start.exe
C:\Users\adels\AppData\Local\Temp\ccifSq1r.o: In function `regChk':
C:/Users/adels/Desktop/EnderCommunity/Projects/Murmur/compiler/libraries/regex/reg.h:15: undefined reference to `__imp_regcomp'
C:/Users/adels/Desktop/EnderCommunity/Projects/Murmur/compiler/libraries/regex/reg.h:22: undefined reference to `__imp_regexec'
C:/Users/adels/Desktop/EnderCommunity/Projects/Murmur/compiler/libraries/regex/reg.h:33: undefined reference to `__imp_regerror'
C:/Users/adels/Desktop/EnderCommunity/Projects/Murmur/compiler/libraries/regex/reg.h:40: undefined reference to `__imp_regfree'
collect2.exe: error: ld returned 1 exit status
Build finished with error(s).
The terminal process terminated with exit code: -1.
Terminal will be reused by tasks, press any key to close it.
So the way that I included this library might be wrong! What am I doing wrong here?
Using MSYS2 will fix this, it comes with all the necessary libraries for C.
I'm new to using wolfSSL. I am trying to compile a set of codes using gcc.
gcc -o main main.c -lwolfssl
I encounter an error of main.c:(.text+0x47b): undefined reference to 'wolfSSL_get_peer_certificate'
collect2: error: ld returned 1 exit status upon entering the statement.
A snippet of the code shows the error location:
fprintf(stderr, "ERROR: failed to connect to wolfSSL\n");
return -1;
}
ret = certverify(CERT_FILE,verifyCert);
WOLFSSL_X509* webCert = wolfSSL_get_peer_certificate(ssl);
I have tried modifying the WOLFSSL_X509* webCert = wolfSSL_get_peer_certificate(ssl); command but it seems to be correct.
I am not too sure why this error is occuring. Can someone please help me with this?
I am using Kali Linux 2019.4 to compile this set of codes.
#wolfSSL_new,
It sounds like the application is failing to link the library so while the right headers are in place to locate the function definitions the final step to link the function is what is failing. Where is libwolfssl.so or libwolfssl.a located on your system? Is it in /usr/local/lib/libwolfssl.so or /usr/local/lib/libwolfssl.a?
(.a is a static library, .so is a shared object library it can be either or)
Once you located where it is try this build command instead (For the sake of an example I am going to assume it is in /usr/local/lib):
gcc main.c -o main -I/usr/local/include -L/usr/local/lib -lwolfssl
Let me know if that resolves the linker error you are seeing.
[UPDATE]
This was resolved by adding the configure setting --enable-opensslextra
[END UPDATE]
Regards,
K
I am creating many threads and each one should output a random number.
I know that srand() with rand is not thread-safe and indeed all the output numbers are the same.
So I tried to use rand_r but I get the following error on my Windows terminal
main.c:47:16: warning: implicit declaration of function 'rand_r'; did you mean 'rand'? [-Wimplicit-function-declaration]
result= ( (rand_r(&seed) % (high+1-low) ) + low);
^~~~~~
rand
main.c: In function 'customerServe':
main.c:333:1: warning: control reaches end of non-void function [-Wreturn-type]
}
c:/mingw/bin/../lib/gcc/mingw32/8.2.0/../../../../mingw32/bin/ld.exe:
C:\Users\allys\AppData\Local\Temp\ccSslADA.o:main.c:(.text+0xe): undefined
reference to `rand_r'
c:/mingw/bin/../lib/gcc/mingw32/8.2.0/../../../../mingw32/bin/ld.exe:
C:\Users\allys\AppData\Local\Temp\ccSslADA.o:main.c:(.text+0x41c):
undefined reference to `rand_r'
collect2.exe: error: ld returned 1 exit status
Thank you
I saw from the post tags that you are using the "pthreads" library which stands for POSIX threads. Therefore this project cannot be run on Windows since it does not support the "lpthread" flag on your system.
If you insist on working on a Windows machine, you could use something like this which lets the developer work on an Ubuntu terminal from windows. While having access to an Ubuntu-like system where the lpthreads library is supported, you can move on with your project. Another possible solution could be using docker to compile & run your project on an isolated ubuntu environment but this is kind of an overkill.
Let me know if this helped!
I needed to specify a late enough Posix source to avoid this warning, e.g.:
gcc -Wall -std=c11 -D_POSIX_C_SOURCE=199506L pi.c -o pi -lm -lpthread
When installing the Haskell GD package through cabal, on Windows (using MinGW), I get the following warnings:
Warning: resolving _gdImagePtrDestroyIfNotNull by linking to _gdImagePtrDestroyIfNotNull#4
Warning: resolving _gdImageCopyRotated90 by linking to _gdImageCopyRotated#36
Use --enable-stdcall-fixup to disable these warnings
Use --disable-stdcall-fixup to disable these fixups
Note that these are precisely the functions defined in gd-extras.
Then, when actually compiling a Haskell program which uses gd, I get the following errors:
Linking Main.exe ...
[...]\cabal\gd-3000.7.3\ghc-7.4.1/libHSgd-3000.7.3.a(Internal.o):fake:(.text+0x2211):undefined reference to 'gdImageCopyRotated90'
[...]\cabal\gd-3000.7.3\ghc-7.4.1/libHSgd-3000.7.3.a(Internal.o):fake:(.text+0x500a):undefined reference to 'gdImagePtrDestroyIfNotNull'
[...]
collect2: ld returned 1 exit status
I'm unable to figure out how to fix this — it's already taken me ages to get to this point, as I've had many more issues trying to get it working, but this seems like the final hurdle. I have tried enabling/disabling stdcall fixup, and also changing in which file these functions are defined (as gd-extras seemed to be a potential issue), but that hasn't adressed the issues.
Thanks for any help.
You need to pass explicit linker flags to ghc, pointing to the library. The Haskell GD library is automatically linked, but the dll will not be linked as well unless you tell ghc about it. The stdcall-fixup errors are a red herring here.
(I'm on Windows.)
I try to build pysox. Therefore I built libsox (part of SoX). It is said, that pysox needs "libsox.so and libsox.a in your link path." When building libsox I got "libsox.a", "libsox-1.dll", "libsox.dll.a", "libsox.la", "libsox.lai" and many other strange files. When I placed "libsox.a" in my link path, the previously shown error disappeared. But now the build script has an error when it calls mingw32-gcc which says:
C:\Programme\MinGW\bin\mingw32-gcc.exe -shared -s build\temp.win32-2.7\Release\pysox\sox.o build\temp.win32-2.7\Release\pysox\sox.def -LC:\Programme\Python\libs -LC:\Programme\Python\PCbuild -lsox -lpython27 -lmsvcr90 -o build\lib.win32-2.7\pysox\sox.pyd
build\temp.win32-2.7\Release\pysox\sox.o:sox.c:(.text+0x3a96): undefined reference to `sox_get_encodings_info'
build\temp.win32-2.7\Release\pysox\sox.o:sox.c:(.text+0x5035): undefined reference to `sox_get_encodings_info'
build\temp.win32-2.7\Release\pysox\sox.o:sox.c:(.text+0x795d): undefined reference to `bcopy'
build\temp.win32-2.7\Release\pysox\sox.o:sox.c:(.text+0xa8b3): undefined reference to `bcopy'
collect2: ld returned 1 exit status
error: command 'mingw32-gcc' failed with exit status 1
The following attempts didn't work:
Placing "libsox-1.dll" in link path
Renaming it to "libsox.dll"
Renaming it to "libsox.so"
Placing all files generated along with "libsox.a" in link path
Do I really need an "so" file on Windows (how do I get it)? Or what has to be changed?
MinGW uses a static interface library for each dynamic link library (DLL). The libsox.dll.a library is the one you need at link time, i.e. that needs to be copied into the link path. libsox-1.dll is required in the PATH at runtime, but not needed at link time.
You don't need a .so file on Windows platforms. It seems that some symbols are missing from the static library libsox.a, or that a library is missing from the link line. Windows platforms do not allow unresolved symbols in DLLs, contrary to UNIX-like .so platforms. You might have to give the library containing sox_get_encodings_info and friends explicitly on the command line, remembering precedence on the linker line.