Link openssl ported library with Native Client(NaCl) Module? - encryption

I am developing a simple chrome extension to encrypt data and upload it to dropbox. I built the openssl library on the link naclports to use in my NaCl module. My makefile is posted on codeshare link. The code is not able to locate the openssl header files, it reports errors as follows:
CXX pnacl/Release/crest.o
In file included from crest.cc:17:
./aes.h:4:10: fatal error: 'openssl/conf.h' file not found
#include <openssl/conf.h>
^
1 error generated.
make: *** [pnacl/Release/crest.o] Error 1
For reference I am also posting links to my sources files:
aes.h header file, aes.c code, crest.cc

You'll want to be sure that the header can be found in your include path.
If built correctly, openssl's headers will go here:
${NACL_SDK_ROOT}/toolchain/linux_pnacl/le32-nacl/usr/include/openssl/conf.h
You'll likely want to add something like this to the compile command line:
-I ${NACL_SDK_ROOT}/toolchain/linux_pnacl/le32-nacl/usr/include

Related

How to add a directory to the search path of GCC (crti.o not found)

I am installing GSI V3.5 https://dtcenter.org/com-GSI/users/. I have no experience in gcc so I cannot use a correct terminolgy for this.
After compiling the program I get an error
” ...........
"/raid60/raid2/opt/local/bin/../lib/gcc/x86_64-conda_cos6-linux-gnu/7.3.0/../../../../x86_64-conda_cos6-linux-gnu/bin/ld:
cannot find Scrt1.o: No such file or directory
/raid60/raid2/opt/local/bin/../lib/gcc/x86_64-conda_cos6-linux-gnu/7.3.0/../../../../x86_64-conda_cos6-linux-gnu/bin/ld:
cannot find crti.o: No such file or directory
/raid60/raid2/opt/local/bin/../lib/gcc/x86_64-conda_cos6-linux-gnu/7.3.0/../../../../x86_64-conda_cos6-linux-gnu/bin/ld:
cannot find -lm
/raid60/raid2/opt/local/bin/../lib/gcc/x86_64-conda_cos6-linux-gnu/7.3.0/../../../../x86_64-conda_cos6-linux-gnu/bin/ld:
cannot find -lgomp "
It seems that there is problem with gcc which cannot find the
directory including Scrt1.0, crti.o and others.I found these files in
this directory
/home/opt/anaconda/x86_64-conda_cos6-linux-gnu/sysroot/usr/lib. Because I do not have adminstration previlage, as suggested, I could
not install packages like libc6-dev. Follwing
https://askubuntu.com/questions/251978/cannot-find-crti-o-no-such-file-or-directory
And
https://askubuntu.com/questions/251978/cannot-find-crti-o-no-such-file-or-directory,
I added the directory above to ~/.cshrc.
setenv LD_LIBRARY_PATH
/home/opt/anaconda/x86_64-conda_cos6-linux-gnu/sysroot/usr/lib
But still gcc does not recognize this path.
I also tried to feed this path into configure using LDFLGAS
> ./configure
> LDFLAGS="-L/home/opt/anaconda/x86_64-conda_cos6-linux-gnu/sysroot/usr/lib"
But no success. At the end I added LDFLAGS into configure
script. But it also did not work. Any help is highly apreaciated.
Of course, the expected answer would be making gcc identify the path
of crti.o and other missing files.
UPDATE:
As Florian Weimer suggested, I made the file crt.specs. I also updated related line in configure. These files are in dropbox link . But I still get the same error.
UPDATE 2.
These are some lines before error occurs:
../write_obsdiags.o ../wrwrfmassa.o ../wrwrfnmma.o
-L/opt/local/wrf_kpp/gsi35/comGSIv3.5_EnKFv1.1/lib -lsp_i4r8 -lsigio_i4r4 -lsfcio_i4r4 -lnemsio -lbacio -lw3nco_i4r8 -lbufr_i4r8 -lw3emc_i4r8 -lcrtm /opt/local/wrf_kpp/WRFV3//external/io_int/libwrfio_int.a
/opt/local/wrf_kpp/WRFV3//external/io_netcdf/libwrfio_nf.a
/opt/local/wrf_kpp/WRFV3//frame/pack_utils.o
/opt/local/wrf_kpp/WRFV3//frame/module_machine.o
/opt/local/wrf_kpp/WRFV3//frame/module_driver_constants.o
-L/home/srvx11/lehre/users/a1276905/.conda/envs/libgsi/lib -lnetcdff -lnetcdf -L/home/srvx11/lehre/users/a1276905/.conda/envs/libgsi/lib -L/home/srvx11/lehre/users/a1276905/.conda/envs/libgsi/lib -llapack -lblas -fopenmp /raid60/raid2/opt/local/bin/../lib/gcc/x86_64-conda_cos6-linux-gnu/7.3.0/../../../../x86_64-conda_cos6-linux-gnu/bin/ld:
cannot find Scrt1.o: No such file or directory
Update 3
I have used option -B to add directory including crti.o to the search path of gcc.
when I invoke
gcc -print-search-dirs
I see my desired path "/home/opt/anaconda/x86_64-conda_cos6-linux-gnu/sysroot/usr/lib" among known paths
libraries:
=/home/opt/anaconda/x86_64-conda_cos6-linux-gnu/sysroot/usr/lib/x86_64-unknown-linux-gnu/5.3.0/:/home/opt/anaconda/x86_64-conda_cos6-linux-gnu/sysroot/usr/lib/:/usr/local/lib/gcc/x86_64-unknown-linux-gnu/5.3.0/:/usr/local/lib/gcc/x86_64-unknown-linux-gnu/5.3.0/../../../../x86_64-unknown-linux-gnu/lib/x86_64-unknown-linux-gnu/5.3.0/:/usr/local/lib/gcc/x86_64-unknown-linux-gnu/5.3.0/../../../../x86_64-unknown-linux-gnu/lib/../lib64/:/usr/local/lib/gcc/x86_64-unknown-linux-gnu/5.3.0/../../../x86_64-unknown-linux-gnu/5.3.0/:/usr/local/lib/gcc/x86_64-unknown-linux-gnu/5.3.0/../../../../lib64/:/lib/x86_64-unknown-linux-gnu/5.3.0/:/lib/../lib64/:/usr/lib/x86_64-unknown-linux-gnu/5.3.0/:/usr/lib/../lib64/:/usr/local/lib/gcc/x86_64-unknown-linux-gnu/5.3.0/../../../../x86_64-unknown-linux-gnu/lib/:/usr/local/lib/gcc/x86_64-unknown-linux-gnu/5.3.0/../../../:/lib/:/usr/lib/
But I am not through.
The linker search path is only used for libraries. It is not used to locate any object files, including the startup object files.
If the toolchain was built with sysroot support, you can use --sysroot to change where GCC looks for most of its files. This may require adding symbolic links or copying files to create a working sysroot environment and can be somewhat cumbersome.
If you want to change just the location of the startup files, you can do so with a custom GCC specs file. What you need to use is unfortunately somewhat dependent on the GCC version and how GCC was built. This means that as a starting point, you need to use the specs built into GCC, which you can obtain using this command:
gcc -dumpspecs
There are two sections in this file, *startfile: and *endfile:, that are of interest. Copy those two lines and the line following each into a new file, say crt.specs. Edit them and replace Scrt1.o, crt1.o, crti.o (in *startfiles:) and crtn.o (in *endfiles:) with the absolute path to the files you want to use (presumable files you have extracted from libc6-dev using dpkg -x).
Then you can use the new specs by invoking GCC using:
gcc --specs=crt.specs
It will definitely save you a lot of trouble if you can get the system administrator to install the libc6-dev package. It is the only safe way to ensure that these files are kept up-to-date along with the libc6 package.

Use dynamic library in dynamic library

I am always using QDesignerCustomWidgetInteface. I want to use two kinds of CustomWidget in another CustomWidget to combine two of them so that I need not to write some codes again.
So I write codes as below in project file:
LIBS +=-L./debug -lxzquxianplugin
LIBS +=-L./debug -lxzyctextplugin
When I finished the code I debug the codes in creator and started debugging designer. Designer ran well and recognized my new CustomWidget. But when I entered bin/gcc/debug folder and ran executable app Designer that debug mode produced directly without codes and Qt creator, Designer showed that could not find shared library: libxzquxianplugin.so.
I tried to use codes as below:
Debug {
LIBS +=absolute path way of xzquxianplugin
LIBS +=absolute path way of xzyctextplugin
}
But it still failed to find dynamic library when I ran Designer in debug folders. I cannot understand why it happened.
the libs -L switch is used when you want to add a directory to linker search path, you used:
LIBS +=-L. /debug -lxzquxianplugin
Which actually breaks your path because of the space after -L.
So you should have
LIBS +=-L./debug -lxzquxianplugin
given that your lib exists under debug folder.

How to install/locate R.h and Rmath.h header files?

I am trying to compile some C code (called rand_beta) in terminal which contains the lines to include R.h and Rmath.h header files using gcc -o rand_beta rand_beta.c so I can then call the code from within R.
However, I get the error messages:
rand_beta.c:1:15: error: R.h: No such file or directory
rand_beta.c:2:19: error: Rmath.h: No such file or directory
It seems that these header files which should come installed with R are not on my system.
Can someone guide me as to how I can get my computer to find the R header files? Do I need to download them from somewhere?
The other answers try to guess where your R installation directory is. But there is a more robust solution. Use the R.home command in R to find it wherever it is:
> R.home('include')
/usr/lib64/R/include
That is the folder containing R.h and Rmath.h on my system. Your folder may be in a different place.
You first need to locate those headers. In my system, they are located in /usr/lib64/R/include/R.h, part of the R-devel package I installed with yum.
Then use the -I option of gcc to tell gcc where to find them.
gcc -I/usr/lib64/R/include -o rand_beta rand_beta.c
Then, you will also most probably need to export LD_LIBRARY_PATH to run your compiled program:
LD_LIBRARY_PATH=/usr/lib64/R/lib ./rand_beta
Another way is to specify some environment variables to directly use the include path:
export CPATH=/usr/lib64/R/include/
export C_INCLUDE_PATH=/usr/lib64/R/include/
export CPLUS_INCLUDE_PATH=/usr/lib64/R/include/
export GCC_INCLUDE_DIR=/usr/lib64/R/include/
This should then run fine:
gcc -o rand_beta rand_beta.c

Qt Error: cannot open include file: 'opencv2/core/core.hpp' no such file or directory

I want to build an opencv project using Qt 5.1_VS2010. I have included the path for opencv include files. But when I run the code, I get the error that specific .hpp file does not exist! I have checked in the directory and it actually exists there! another point that when I was trying to include it in my main c++ file, the auto completion guide actually helped me complete the whole path! so it means the directory and the header file was already recognized! anyway, part of my .pro file that includes the path is like this:
INCLUDEPATH += "C:/opencv/build/include"

Undefined references - I'm including correct header

I'm trying to subclass from ProjectExplorer::ProjectExplorerPlugin but I'm getting error telling me about undefined references. Any ideas how to fix it?
class MyPluginPlugin : public ProjectExplorer::ProjectExplorerPlugin
{
Q_OBJECT
...
};
error: undefined reference to `imp__ZN15ProjectExplorer21ProjectExplorerPluginC2Ev'
The fact that you don't get a compilation error, but an undefined reference usually means that your project knows where the header files are, but it doesn't know where the library is which contains the already compiled source code.
I've never written a plugin for Qt Creator but I've taken a quick look at its source code structure and I see the following options:
Option A)
There is a projectexplorer.pro file in Qt Creator's source under src/plugins/projectexplorer. You could manually build that project in order to get a ProjectExplorer.lib (plus a .dll or a .a) and then reference this library.Example: Assuming the library would be created in the same directory as its .pro file (I have no idea if it is like that) and you created your plugin withing Qt Creator's source under src/plugins/myplugin, you would define your LIBS variable like this:
LIBS += -L../projectexplorer \
-lProjectExplorer
The first line adds "../projectexplorer" as an additional library directory and the second line adds "ProjectExplorer" as a library to search in any of the defined directories (it automatically adds the OS-specific file extensions like .lib on windows etc).
Obviously if your project or the library is located somewhere else, you need to change the first line accordingly.
Option B)
You could include the source and header files of the projectexplorer directory to your own .pro file using the HEADERS and SOURCES variables. I'm not sure if this wouldn't interfere with any other plugins (including projectexplorer itself) though.
Option C)
There probably is a way to include the projectexplorer.pro file so that you have a master project which first builds the project explorer library and then your own plugin. This would be the safest way to go as it ensures the Project Explorer library is built and up-to-date before your own project is linked against it.
However I have limited experience on this.
If anyone reading this can give a detailed explanation on this option, feel free to edit or provide your own answer.
If you are using Qt Creator built from source coded after April 2013 which includes Commit: #66a3553 - make library and plugin dependencies declarative, then you can simply specify dependencies for your plugin in its .pro file:
# myplugin.pro
QTC_PLUGIN_DEPENDS += \
coreplugin \
projectexplorer

Resources