Electron crashes with C++ addon using openssl library - c++

I am trying to run with Electron a C++ addon that links to the openssl library. When the C++ code tries to access the library I get an exception: Procedure not found. I found another similar question here, but I could not manage to make it work, as the original poster said it would. I tried to link to a static compiled library from here, specifically libeay32MT.lib but when running under Electron it still crashes.
In bindings.gyp I have the library added like this:
"-l$(OPENSSL_ROOT)/lib/libeay32MT.lib"
Any ideas how I can make this work?

I managed to find the problem: I was also linking to node.lib inside the bindings.gyp. It wasn't necessary, but I "inherited" it from the Visual Studio proj file, where the node.lib was mandatory in order to compile the addon for node.
After removing the unnecessary library link to node.lib from the bindings.gyp the electron app worked just fine.

Related

Poco FindMySql.cmake not able to find MySQL source

I'm working with a bit of a legacy cpp code base. This code base is reliant on Poco, more specifically Poco/MySQL.
When loading Poco via Cmake, it attempts to find the MySQL include and libs. I have the source code of MySQL in a folder nearby, and am attempting to link it in the CMake. While I was able to get the include directory linked correctly, it's still not finding mysqlclient(_r) and I have no idea why. I'm currently attempting in on Mac, but I'd like to make it cross platform as well.
FindMySQL.cmake:
find_library(MYSQL_LIB NAMES mysqlclient_r
PATHS
/usr/lib/mysql
/usr/local/lib/mysql
/usr/local/mysql/lib
/usr/local/mysql/lib/mysql
/opt/mysql/mysql/lib
/opt/mysql/mysql/lib/mysql
$ENV{MYSQL_DIR}/libmysql_r/.libs
$ENV{MYSQL_DIR}/lib
$ENV{MYSQL_DIR}/lib/mysql
${CMAKE_CURRENT_SOURCE_DIR}/../../mysql/lib
${CMAKE_CURRENT_SOURCE_DIR}/../../mysql/libmysql)
message("${MYSQL_LIB}") # MYSQL_LIB-NOTFOUND
https://github.com/mysql/mysql-server
That's the MySQL source I'm attempting to build.
After a very long time I found the answer.
Changing it to include_library instead worked fine as it was an include only library.

My project can't find its libraries when run manually from the terminal

I'm creating a library for the first time. So far it's working from the IDE (Qt Creator), but not from the terminal when I run its testing program manually.
There are two parts to my project, the library, and the sandbox for testing it. I've created a project in Qt Creator that includes two subprojects (one to build the lib, and one to build the tester) and both compile without errors. When I run the sandbox from the IDE the library is dynamically linked to the sandbox, the function greeting() is loaded in from it, then called, and prints "Welcome to the library!" to std::cout. However, if I open the build folder in the terminal and run the sandbox directly using ./sandbox I get:
./sandbox: error while loading shared libraries: libengine.so.1: cannot open shared object file: No such file or directory
I took this to mean that I needed to properly install my custom library, libengine.so.1. When I looked up how to do that I found that I just needed to copy the library files in to either, /usr/lib or /usr/local/lib, but neither of those worked and I'm still getting the above error. In the past, that simple solution did work for me when compiling a 3rd party library (SDL, I think) and I don't know what I'm missing that would mean it wouldn't work now. So far I haven't yet found any more detailed information and I don't know what I'm doing wrong or have missed.
How do I make my sandbox program see its companion library when I run it directly from the command line?
NOTE: I'm specifically asking about Linux/Ubuntu. If I later run into problems under Windows I'll be back. :-)
Short Answer
I ran in to multiple problems all at once.
First problem: Broken symbolic links (they're like shortcuts in Windows).
Second: My lib needed to be copied in to a different system directory than is generally recommended.
Third: Qt Creator and QMake made passing custom linker options difficult.
The Details
When Qt Creator compiles my library it automatically creates three symbolic links to it with different layouts of the version numbers.
> ll
lib-engine.so -> lib-engine.so.0.1.0
lib-engine.so.0 -> lib-engine.so.0.1.0
lib-engine.so.0.1 -> lib-engine.so.0.1.0
lib-engine.so.0.1.0 (original library file)
For some reason (I don't know why) each time I moved the links in to a system directory like usr/local/lib the links would break. I didn't notice this at first, or even think to check, because that's never happened to me before. Moving a link has always worked in the past. To get around this I just manually created the links within the directories they would reside in.
Broken links aside, putting the library in to usr/local/lib still didn't work, but usr/lib and /usr/lib/x86_64-linux-gnu (recommended in the blog linked below) did work!
Those fixes actually came after a different fix I looked in to after reading this blog and this article it linked to.
There it said to add -Wl,-rpath,'$ORIGIN/lib' to the gcc build options to embed a library search path in to the application itself. This set of options would allow me to put my library files where ever I wanted (specifically, in a directory called /lib in the application's working directory).
Unfortunately, that had two problems of its own. First, Qt Creator doesn't (from what I can tell) allow you to specify custom build options for individual subprojects through the GUI, so I had to figure out how to add linker options using the project file, assuming that was possible, which it was.
Second, QMake messed up the gcc options, embedding in to my application Library rpath: [RIGIN/lib] instead of Library rpath: [lib] like it's supposed to.
In the end, changing the proposed linker options of...
-Wl,-rpath,'$ORIGIN/lib'
... to the following QMake project file line...
QMAKE_LFLAGS += -Wl,-rpath,'lib'
... work out nicely. Using both fixes I can now either install my library on my system or put it in to a /lib folder and the program will run.

How to get AssImp to work properly?

I have been trying to do this for about a week with no good anyhow. I am building a .dll (UNDONE Engine .dll) that depends upon Assimp to load models. The .dll compiles and links with no problems at all, but when I try to use it with some application, I get the following error:
'Test_Game.exe' is the application I made that uses the .dll library that is using assimp.
I downloaded assimp from the sourceforge repository. I got the version 3.0 SDK for windows, installed it and I did do whatever was nessesary to get the project linked.
Here is how the directory with the .exe looks like:
I have included the right bitness of the lib, that is 32 bit versions.
Why does it not work? Is there some internal bug inside Assimp which prevents me from using it? Or is there something I am missing? Is it causing problems because i am using it from a dll? Can you please get me through the steps to install and use properly? I use visual studio 13.
EDIT
After running Dependency walker over my exe, I get this:
And I have very less idea of what that means, but, just guessin, does it mean that assimp.exe has some undefined functions?
What depends.exe is telling you is that undone_engine.dll's import table includes an entry for AssImp.exe, which includes an entry for the function ??0Importer#AssImp##QAE#XZ and some friends. Windows then expects to find the functions ??0Importer#AssImp##QAE#XZ and friends in the export table of AssImp.exe.
Depends is also telling you that there is nothing in the export table of AssImp.exe, which is unsurprising, as exe's seldom export anything. Interestingly, it's also telling you that assimp.exe imports assimp32.dll.
You're probably intending to link with assimp32.lib, not assimp.lib. (#Dirk hints at this in the comments; I suspect he's nailed it.) Do you have an assimp32.lib that you could try linking against instead of assimp.lib?
I wonder if AssImp32.dll imports code from the static library ButtGremlin.lib? /twelveyearold

JNI system.loadlibrary problem - native C++ dll using C library

I have a pretty annoying compiling problem.
I am trying to do a System.loadlibrary on a C++ DLL in VS2010, which in turns uses a C DLL compiled in VS2008.
The error I am getting is:
java.lang.UnsatisfiedLinkError: The application has failed to start because
its side-by-side configuration is incorrect
This occurs whenever my C++ DLL tries to do a call to a function in the C DLL. Both compiles just fine, and both are in a folder accessible by Java Applet.
Is this possible to solve somehow? Do you need any more info?
You should try and use the dependency walker on your DLLs.
From the side-by-side error I assume that one of the c runtime redist packages or one of the noredist packages is missing.
But the dep walker should show you this.
If this does not help you can get some more information from the event log of Windows since side by side errors are logged there, or you need to use sxstrace for more info.
Have you installed the runtimes of VC2010 and VC2008?
Additionally you have to make sure the manifests of both DLLs are correctly configured so that the correct version of the used library can be loaded.
See also: http://msdn.microsoft.com/en-us/library/ms235342.aspx

Using OpenSSL's CMS implementation in C++

So my project today has been to create a C++ class that consolidates a lot of our commonly used crypto tasks. Got lots of things working but ran into a bit of a snag here. For reference, I'm using XCode 3.2.5 on OS 10.6.5.
I'm attempting to utilize some of OpenSSL's CMS functions. OpenSSL's MAN Page for one of the functions I'm trying to use mentions it was included in version 0.9.8. That's the version XCode let me import without having to do anything out of the ordinary (Target -> General -> Add Linked Library). Yet with that added XCode tells me it can't find openssl/cms.h.
So thinking maybe there's some disparity between the OS X version 0.9.8 and the one on OpenSSLs page, I downloaded the source for 1.0.0c and built it. After it was built, I added libcrypto.a and libssl.a to my project as linked libraries and added "some/dirs/openssl-1.0.0c/include/**" as a header search path. Now it can find openssl/cms.h but I get a linking error on any CMS function I call.
Has anyone done this successfully? Any help would be appreciate.
Thanks!
So what I ended up doing was to create a new SDK and calling,
./Configure darwin64-x86_64-cc --prefix=/path/to/sdk/usr --openssldir=/System/Library/OpenSSL enable-cms shared
To update the version of OpenSSL included in that SDK. That's seemed to work.