How to add cryptopp to project in OMNeT++ - c++

First, I built the cryptlib (of cryptopp) in Visual Studio Code 2022. And tried a sample c++ program (using files from the library) and it worked fine.
Then, I included the library cryptlib.lib in my OMNeT++ project.
I also included the cryptopp folder for the .cpp and .h files of the library.
But when I build the omnet++ project, I get this error:
03:05:22 **** Incremental Build of configuration debug for project crypto_final ****
make MODE=debug all
cd src && /usr/bin/make
make1: Entering directory '/d/omnetpp-5.7/samples/crypto_final/src'
Server.cc
Creating executable: ../out/clang-debug/src/crypto_final_dbg.exe
lld-link: error: could not open 'liblibcpmt.a': No such file or directory
lld-link: error: could not open 'libLIBCMT.a': No such file or directory
lld-link: error: could not open 'libOLDNAMES.a': No such file or directory
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [Makefile:99: ../out/clang-debug/src/crypto_final_dbg.exe] Error 1
make[1]: Leaving directory '/d/omnetpp-5.7/samples/crypto_final/src'
make: *** [Makefile:2: all] Error 2
"make MODE=debug all" terminated with exit code 2. Build might be incomplete.
03:05:25 Build Failed. 2 errors, 0 warnings. (took 3s.352ms)
I don't even know what are these libraries or how to get them built.
Can anyone help, please?
Edit #1: btw, when I change the Target type from "Executable" to "Static library (.lib or .a) in makemake options, the project builds normally but does not run properly (has some bugs and no effects can appear on the simulation)

OMNeT++ project uses Makefile, therefore to add an external library or class one should modify makefrag.
You should go to Project | Properties | OMNeT++ | Makemake | select root or src of your project | Options, then Custom | Makefrag and write the following lines:
EXTRA_OBJS += -L/d/foo/lib -llibcpmt -lLIBCMT -lOLDNAMES
CFLAGS += -I/d/foo/include
where /d/foo/lib is an example of the directory which contains your cryptlib static files (e.g. liblibcpmt.a, libLIBCMT.a, ... ), and /d/foo/include - the directory that contains header files of cryptlib.

Omnet++ useses MinGW as the runtime system and the C++ compiler's ABI is incompatible with the MS ABI (i.e. C++ code generated by Visual Studio C++ compiler is incompatible with the code generted by gcc or clang).
You MUST compile your crypto library also with the clang compiler coming with OMNeT++. Visual Studio compiler will NOT work.
Or... OpenSSL libraries and headers are already available in the Windows distro, so you can pt to use that.

Related

How can I run many C++ source files in one CLion project?

I am using CLion as an IDE. When I create a project a main.cpp is automatically added. I would like to add 30-40 cpp files in a project and keep them as one project. Basically, I just wanna create many .cpp files in one folder and make CLion run them. I can do this in Pycharm by simply creating a project and add as many .py files as I want. But when I want to do this on CLion I got an error. Is it possible to add many .cpp files in a project in CLion, if yes, how can I do that?
An error could be seen in the below. I added a second.cpp to the project and run and this error message appears.
====================[ Build | trial | Debug ]===================================
/Applications/CLion.app/Contents/bin/cmake/mac/bin/cmake --build /Users/mertsaner/CLionProjects/trial/cmake-build-debug --target trial -- -j 6
Scanning dependencies of target trial
[ 66%] Building CXX object CMakeFiles/trial.dir/main.cpp.o
[ 66%] Building CXX object CMakeFiles/trial.dir/second.cpp.o
[100%] Linking CXX executable trial
duplicate symbol '_main' in:
CMakeFiles/trial.dir/main.cpp.o
CMakeFiles/trial.dir/second.cpp.o
ld: 1 duplicate symbol for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[3]: *** [trial] Error 1
make[2]: *** [CMakeFiles/trial.dir/all] Error 2
make[1]: *** [CMakeFiles/trial.dir/rule] Error 2
make: *** [trial] Error 2
Clion uses Cmake. If you want to create multiple executable files for eg with names (ex1.cpp, ex2.cpp. ex3.cpp) in one directory, you will do something like this in the CMake file of your directory.
cmake_minimum_required(VERSION 3.18)
project(some_project)
set(CMAKE_CXX_STANDARD 20)
add_executable(executable1 ex1.cpp)
add_executable(executable2 ex2.cpp)
add_executable(executable3 ex3.cpp)
and so on..

Building OpenCV using makefile throwing error?

I was trying to setup OpenCV environment using MingW64 and visual studio code,
Work done so far
Installed and set environment CMake
Installed OpenCV 4.5.2
OpenCV Makefile generation
using CMake Build from source(openCV directory)
specified the generator for the project
configured the compiler type and makefile type
Enabled precompiled header
Confusing part
when I entered the command mingw32-make for compilation in directory where the makefile is generated
It worked until 67% after that:
[ 67%] Built target pch_Generate_opencv_test_dnn
Scanning dependencies of target opencv_test_dnn
[ 67%] Building CXX object modules/dnn/CMakeFiles/opencv_test_dnn.dir/test/npy_blob.cpp.obj
In file included from <command-line>:0:0:
D:/opencv/build/modules/dnn/test_precomp.hpp:50:10: fatal error: test_common.hpp: No such file or directory
#include "test_common.hpp"
^~~~~~~~~~~~~~~~~
compilation terminated.
mingw32-make[2]: *** [modules\dnn\CMakeFiles\opencv_test_dnn.dir\build.make:82: modules/dnn/CMakeFiles/opencv_test_dnn.dir/test/npy_blob.cpp.obj] Error 1
mingw32-make[1]: *** [CMakeFiles\Makefile2:3429: modules/dnn/CMakeFiles/opencv_test_dnn.dir/all] Error 2
mingw32-make: *** [Makefile:181: all] Error 2
thank you

Clion: How to configure clion when Opening existing folder there is no debug and run menu?

I'm using CLion 2021.1.1 version. I'm a new user. I've done some cpp programs on codeblocks. But Whenever I open an existing folder the files are showing but there is no debug option. It says Add configuration. There is no run option. I've added MingW in buil, execution, Deployment -> Toolchains-> mingw but still it says add configuration. I've close it open new projects in CPP but still getting add configuration. How can open the existing folder and it has many cpp files that I can run each and every cpp file. How can achieve this?
sometimes I get this error:
CMake Error at C:/Program Files/JetBrains/CLion 2021.1.1/bin/cmake/win/share/cmake-3.19/Modules/CMakeTestCCompiler.cmake:66 (message):
The C compiler
"C:/MinGW/bin/gcc.exe"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: O:/1.Fourth Semester/Programming/Algorithm/cmake-build-debug/CMakeFiles/CMakeTmp
Run Build Command(s):C:/MinGW/bin/mingw32-make.exe cmTC_d8b71/fast && C:/MinGW/bin/mingw32-make.exe -f CMakeFiles\cmTC_d8b71.dir\build.make CMakeFiles/cmTC_d8b71.dir/build
mingw32-make.exe[1]: Entering directory 'O:/1.Fourth Semester/Programming/Algorithm/cmake-build-debug/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_d8b71.dir/testCCompiler.c.obj
C:\MinGW\bin\gcc.exe -o CMakeFiles\cmTC_d8b71.dir\testCCompiler.c.obj -c "O:\1.Fourth Semester\Programming\Algorithm\cmake-build-debug\CMakeFiles\CMakeTmp\testCCompiler.c"
CMakeFiles\cmTC_d8b71.dir\build.make:83: recipe for target 'CMakeFiles/cmTC_d8b71.dir/testCCompiler.c.obj' failed
mingw32-make.exe[1]: *** [CMakeFiles/cmTC_d8b71.dir/testCCompiler.c.obj] Error 1
mingw32-make.exe[1]: Leaving directory 'O:/1.Fourth Semester/Programming/Algorithm/cmake-build-debug/CMakeFiles/CMakeTmp'
Makefile:139: recipe for target 'cmTC_d8b71/fast' failed
mingw32-make.exe: *** [cmTC_d8b71/fast] Error 2
CMake will not be able to correctly generate this project
Someone help, please

How can I solve this compiling error on CLion?

I use as the main directory one called CLionProjects, on it I have several directories. Recently I added those directories so to organize my files. I used since the first time I installed CLion a directory called "Boletin1" that it's inside the main directory, later when I created "Boletin2" (In these directories I have the projects called Ejercicio1, Ejercicio2 and so on) the problems started showing up, I get this error message:
I got to make clear that the compiler problem is only on "Boletin2" directory and the one called "Boletin1" works alright.
I type the debug:
"C:\Program Files\JetBrains\Nueva carpeta\CLion 2020.2.3\bin\cmake\win\bin\cmake.exe" -DCMAKE_BUILD_TYPE=Debug -G "CodeBlocks - MinGW Makefiles" C:\Users\usuario\Desktop\CLionProjects\Boletín2\Ejercicio1
-- The C compiler identification is GNU 8.1.0
-- Check for working C compiler: C:/mingw64/bin/gcc.exe
-- Check for working C compiler: C:/mingw64/bin/gcc.exe - broken
CMake Error at C:/Program Files/JetBrains/Nueva carpeta/CLion 2020.2.3/bin/cmake/win/share/cmake-3.17/Modules/CMakeTestCCompiler.cmake:60 (message):
The C compiler
"C:/mingw64/bin/gcc.exe"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: C:/Users/usuario/Desktop/CLionProjects/Boletín2/Ejercicio1/cmake-build-debug/CMakeFiles/CMakeTmp
Run Build Command(s):C:/mingw64/bin/mingw32-make.exe cmTC_a9874/fast && C:/mingw64/bin/mingw32-make.exe -f CMakeFiles\cmTC_a9874.dir\build.make CMakeFiles/cmTC_a9874.dir/build
mingw32-make.exe[1]: Entering directory 'C:/Users/usuario/Desktop/CLionProjects/Bolet�n2/Ejercicio1/cmake-build-debug/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_a9874.dir/testCCompiler.c.obj
C:\mingw64\bin\gcc.exe -o CMakeFiles\cmTC_a9874.dir\testCCompiler.c.obj -c C:\Users\usuario\Desktop\CLionProjects\Boletín2\Ejercicio1\cmake-build-debug\CMakeFiles\CMakeTmp\testCCompiler.c
gcc.exe: error: C:\Users\usuario\Desktop\CLionProjects\Boletín2\Ejercicio1\cmake-build-debug\CMakeFiles\CMakeTmp\testCCompiler.c: No such file or directory
gcc.exe: fatal error: no input files
compilation terminated.
mingw32-make.exe[1]: *** [CMakeFiles\cmTC_a9874.dir\build.make:85: CMakeFiles/cmTC_a9874.dir/testCCompiler.c.obj] Error 1
mingw32-make.exe[1]: Leaving directory 'C:/Users/usuario/Desktop/CLionProjects/Bolet�n2/Ejercicio1/cmake-build-debug/CMakeFiles/CMakeTmp'
mingw32-make.exe: *** [Makefile:140: cmTC_a9874/fast] Error 2
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:2 (project)
-- Configuring incomplete, errors occurred!
See also "C:/Users/usuario/Desktop/CLionProjects/Boletín2/Ejercicio1/cmake-build-debug/CMakeFiles/CMakeOutput.log".
See also "C:/Users/usuario/Desktop/CLionProjects/Boletín2/Ejercicio1/cmake-build-debug/CMakeFiles/CMakeError.log".
[Failed to reload]
Thanks 4 the support or even reading this.
Try to rename your directory to Boletin1 and Boletin2
REMOVE ALL ACCENTS and write it with the boring i letter, even if the spelling is then wrong in your language.
This is an encoding problem and it occurs because in this case you have 3 programs (here cmake, gcc.exe and mingw64-make.exe) that parse the same character with different results (which are Bolet�n2, Bolet├¡n2 and Boletín2).
You might also have to reset clion's cache and/or remove projects from the IDE and re-import them. It may have kept some path in cache and might try to feed them to cmake.

Linking SFML in CodeLite

Ok so I am trying to link SFML in a CodeLite project but with no success. So what have I done :
Added the include folder of SFML to the IncludePaths of CodeLite.
Added the lib folder of SFML to the LibrariesSearchPath of CodeLite.
Added SFML_STATIC to Preprocessors in CodeLite.
Added the libraries to the LinkerOptions like this :
sfml-graphics;sfml-window;sfml-audio;sfml-network;sfml-system
Added the 5 dll's(sfml-graphics-2.dll.. etc) to the debug folder and to the project folder
This is the build log :
C:\WINDOWS\system32\cmd.exe /C ""E:/Program Files (x86)/CodeBlocks/MinGW /bin/mingw32-make.exe" -j4 SHELL=cmd.exe -e -f Makefile""
"----------Building project:[ Test - Debug ]----------"
mingw32-make.exe[1]: Entering directory 'F:/Dropbox/Programming/OpenGL/Test'
"E:/Program Files (x86)/CodeBlocks/MinGW/bin/g++.exe" -o ./Debug/Test #"Test.txt" -L. -LF:/Dropbox/Programming/SFML/SFML-2.3.2x86/lib sfml-graphics sfml-window sfml-audio sfml-network sfml-system
g++.exe: error: sfml-graphics: No such file or directory
g++.exe: error: sfml-window: No such file or directory
g++.exe: error: sfml-audio: No such file or directory
g++.exe: error: sfml-network: No such file or directory
g++.exe: error: sfml-system: No such file or directory
mingw32-make.exe[1]: *** [Debug/Test] Error 1
Test.mk:78: recipe for target 'Debug/Test' failed
mingw32-make.exe[1]: Leaving directory 'F:/Dropbox/Programming/OpenGL/Test'
mingw32-make.exe: *** [All] Error 2
Makefile:4: recipe for target 'All' failed
====1 errors, 0 warnings====
I am using CodeLite 9.0.9 and SFML-2.3.2x86.
1. "Starting from SFML 2.2, when static linking, you will have to link
all of SFML's dependencies to your project as well. This means that
if you are linking sfml-window-s or sfml-window-s-d for example, you
will also have to link opengl32, winmm and gdi32. Some of these
dependency libraries might already be listed under "Inherited
values", but adding them again yourself shouldn't cause any
problems."
Your linked libraries should have -s suffix if you're linking statically and you should link other libraries look at this.
2."When linking to multiple SFML libraries, make sure that you link them in the right order, it is very important for GCC. The rule is that libraries that depend on other libraries must be put first in the list. Every SFML library depends on sfml-system, and sfml-graphics also depends on sfml-window. So, the correct order for these three libraries would be: sfml-graphics, sfml-window, sfml-system -- as shown in the screen capture above." Set linking order to graphics-s/window-s/system-s/etc
3."It is important to link to the libraries that match the configuration: "sfml-xxx-d" for Debug, and "sfml-xxx" for Release. A bad mix may result in crashes."
From your build log I can see that you're building your project as Debug with Release libraries(those without -d suffix), then you have to change linked libraries to sfml-graphics-s-d/etc
If advices above won't work then you set search paths wrong. Good luck
Ok so I finally managed to fix it by changing the libraries like this : -lsfml-graphics-s;-lsfml-window-s;-lsfml-audio-s;-lsfml-network-s;-lsfml-system-s;-lopengl32;-lfreetype;-ljpeg;-lwinmm;-lgdi32;-lopenal32;-lws2_32