Forum Replies Created
-
AuthorPosts
-
dgv
MemberHello Mihai,
Short answer (long answer below):
0/ I assume you have built the package with libudev. If not, please look at the configure output transcript and
replace below “-ludev” with the flags found by “configure”.1/ in your file “main.cpp”, replace
#include “truerng.h”
by// tell the C++ compiler we are using C code: extern "C" { #include "truerng.h" }2.a/ link with static library (libtruerng.so in the directory):
g++ -Wno-write-strings -o main main.cpp ./libtruerng.a -ludev2.b/ link with static library (libtruerng.so removed from the directory):
g++ -Wno-write-strings -o main main.cpp -L. -ltruerng -ludev2.c/ link with shared library:
g++ -Wno-write-strings -Wl,-rpath=pwd-o main main.cpp -Lpwd-ltruerng -ludevExplainations (long answer): It seems to me that you have several issues, which I will discuss separately.
A/ You write your program in C++
The library is written in C, not in C++. So the fundamental problem is to call an external function written in a foreign language.
The basic principle is to tell the C++ main pgm that the library is in C.
This is why you should apply step 1/ above.B/ warning: deprecated conversion from string constant to ‘char*’
This is because the prototypes are declared with “char *” and the compiler wants “const char *”.
I admit I should have done that 🙁
The easy solution is to add an option telling the compiler to shut up because you know what you’re doing.
Use -Wno-write-strings when compiling.C/ linking with dynamic versus static library
You should put the “-ltruerng” option *after* “main”; because the linker goes from left to right for unresolved symbols.
I recommend to link with the static lib, which is easier for testing. So either you build the package
with “./configure … –disable-shared”, or you “rm libtruerng.so*”, or you explicitly use the static library filepath.D/ the output of your main program
When you call “./main”, you should see 10 “scrambled” characters, since the main pgm prints directly the random characters.
You may prefer to pipe the output into “od(1)” in order to have a human-readable output:
./main | od -xE/ I warmly recommend using a Makefile. This permit encapsulating flags, and easy modification.
Indeed, a Makefile is an integral part of your testing procedure. Here is a proposal:PROG = main CXXFLAGS = -Wno-write-strings LOADLIBES = ./libtruerng.a LDLIBS = -ludev .PHONY: all check clean all: $(PROG) check: all ./$(PROG) | od -x clean: $(RM) $(PROG).o $(PROG) $(PROG).core coreBest regards,
Denis/
dgv
MemberHello random guys,
I just received a TrueRNGpro device and I took a week-end to write an OpenSSL engine for it.
I have wrapped up as a GNU package, with the “./configure –prefix=… -enable…” things — with a GNU-compatible license.
Done on a Debian Linux, not tried/tested on any other system. Should work with TrueRNG.
If you are interested, just tell me how to send you the package.cheers,
Denis/
-
AuthorPosts
