Is there a better way to resolve emacs lib dependency? - unit-testing

I came across a problem when I tried to run the test files in a emacs project.
For example, I cloned this project into my home directory, cd into test dir and then used emacs -batch -l ert -l nrepl-tests.el -f ert-run-tests-batch-and-exit to run the tests. But it couldn't locate the file nrepl.el which was not in the same directory. So, I copy one into ~/nrep.el/test. But it said "Cannot open load file: clojure-mode". That is the question I'm concered.
I do have clojure-mode and other libs nrepl.el use. But they are all in different directory(In my case, ~/emacs.d/packs/live/clojure-pack/lib/). Do I have to duplicate these files into my cloned nrepl project in order to run the test? Is there a better way to run test files like we do in IDE. For instance, in Intellij, I simply write import statements in test files, and it automatically prepares the dependency libs for me. This bothers me quite a lot. I'm wondering if there is a best practice for this problem.

If I understand you correctly, I'm under impression that Carton is precisely what you're looking for to overcome these dependency issues: package maintainer is expected to write a small file containing package dependencies including development ones, like ert, and run emacs via carton exec which will make sure everything is downloaded to a certain directory and this directory is added to load-path.

Related

Codelite not recognizing ns-3 files

I'm pretty new with C++ development, and I wanted to use an IDE. I downloaded codelite, and everything was working fine.
The issue
Recently I started development an App for the NetworkSimulator3 or Ns3, that runs with Waf(https://waf.io/). Using the codelite just for my app, and doing the build&Run on the terminal with waf seems wrong.
In the end, codelite is not recognizing a butch of files of ns3, and keep pointing errors.
What I tried to do
I tried adding all Ns3 files in a single workspace, together with my app files, in hopes that everything would work. Instead I still got a bunch of "No such file or directory" errors, although these files exist and are added on the IDE
On the import, Ns3 demands us to call it like this:
#import <ns3/packet.h>
Although the .h is inside another folder:
src/network/model/packet.h
There are a few wscripts files that probably work on these bindings, although I'm not 100% sure.
So I also tried:
Adding the .h in the same folder of my app
Creating a new virtual folder called ns3, and adding the headers there
Including the folder with the headers in the compiler's include paths
Including the folder with the headers in the linker like it was a library
Nothing worked so far
I just wanted to open the Ns3 on an IDE so I could work without several errors showing. Maybe even with some autocomplete?
Could you guys help me figure this out?
Edit
I also added a "Custom build", so I can execute and build my project using waf, but the IDE errors didn't disappear
On the import, Ns3 demands us to call it like this: #import <ns3/packet.h> Although the .h is inside another folder: src/network/model/packet.h
Headers imported with <ns3/header.h> are copied from src/module/(model/helper) to build/ns3 when you build ns-3. You need to add build/ as an include folder (e.g. -I/path/to/ns-3-dev/build), which will make <ns3/header.h> work correctly.
Not sure on the other issues, since I've never tried CodeLite.
I just wanted to open the Ns3 on an IDE so I could work without several errors showing. Maybe even with some autocomplete?
If I may recommend, try the CMake buildsystem. Clone the code and create a cmake cache folder (e.g. mkdir cmake_cache), then generate the CodeLite project (e.g. cd cmake_cache && cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=1 -G "CodeLite - Ninja" .., or -G "CodeLite - Unix Makefiles") and then open the project in cmake_cache with CodeLite. :)
Update: just read on their blog that exporting compile commands is required for code completion when using cmake.
https://codeliteide.blogspot.com/2014/02/codelite-ide-60-cmake-and-clang-code.html

Unable to execute .cpp files in CLion using the console and make commands (Windows 10)

I got a bunch of .cpp files in a project in the CLion IDE which I would like run in order to see what the code is actually doing. The makefile looks like this:
## ptp test
run-ptp: create-ptp
./systems/ptpTest/build/ptpTest
To run the code I went to the console and went to the project root directory which contains the .cpp files I like to run. When I enter the make command "make run-ptp" on the console it returns:
The "make" command is either misspelled or could not be found.
What could possibly be the reason for this to happen and how can I make it work, so that I can run the .cpp files via console and make command? Thanks in advance.
It means either (a) you don't have make installed on your system, or (b) you have it installed but the directory it's installed into is not on your PATH so your shell can't find it, or (c) you have it installed and it's on your PATH but it's installed using a different name than make such as gmake or something like that.
Since you haven't described what operating system you're using nor how you installed make on it that's the best we can do.

How can I set up a minimal c++ makefile and project structure in windows, to be run via command line?

Analogous setup on *nix:
There is a single project folder with a makefile, and directories for src, build, and target.
In the src directory, I put main.cpp, and other source files (file_0.cpp, file_0.h, file_1.cpp, file_1.h, etc...).
Invoking the makefile (via make, or similar one-line [preferably one-word] script) does nothing fancier than check the src folder if anything is newer than the target, and if so, rebuilds the whole project. (Alternatively, a batch file that just does the compilation regardless of filesystem state would also be "fine"- though I'd prefer a makefile as I could iteratively grow that in complexity as necessary.)
The "build" folder could be used for intermediate build files.
Questions:
What do I need to install? How must I set up my environment? What compilers/tools should I lean into so I'm not fighting the OS? Etc...
My needs for these projects are minimal. The point here is I DON'T want to have to rely on booting up a heavy IDE or similar to putz around with simple C++ projects. Is this achievable in Windows 10?
Problems:
I've tried installing mingw, with msys, and can get cl to produce a .exe, but when I invoke it via a makefile, I get LINK : fatal error LNK1104: cannot open file 'LIBCMT.lib'. I've been struggling to find "makefile" resources for windows, as many appear to be straddling different tech stacks (cl vs g++, make vs nmake, etc...)

How to run c++ program written in eclipse, from terminal

I'm using Ubuntu and I have written my c++ code in Eclipse Neon.
My workspace contain 4 projects. The main project is called BaseCppProjectRun (it contains main.cpp file) and I have other projects with these names: Encoders, frmwrk, NetworkLayer - the BaseCppProjectRun using each one of them.
If I running my program directly from eclipse everything works.
But I want to running my program from terminal - and I can't.
Because When I'm trying to run my progrm like this:
root#ubuntu:/builds/BaseCppProject/BaseCppProjectRun# ./Debug/BaseCppProjectRun
I'm getting this error:
./Debug/BaseCppProjectRun: error while loading shared libraries: libfrmwrk.so: cannot open shared object file: No such file or directory
As I said before, if I'm running it directly from eclipse everything works.
How can I run my program from terminal?
How is Linux supposed to know where to find libfrmwrk.so, if you don't put that either where it normally looks nor tell it where it can be found.
Eclipse seems to set up the paths the runtime linker looks into so, that when your program is loaded, the runtime linker knows where to find your libfrmwrk.so and so on.
You'll either have to
install these libraries (.so's) so that they are found in default locations, or
set LD_LIBRARY_PATH to contain all the folders to look into.
I haven't worked with Eclipse CDT in ages, but you can by now probably export some project formats that allow you to easily install things.
Another thing: It seems you're running software you're still debugging as root: That is a terrible idea, and if it can be avoided, avoid it.
I finally figure it out!
Refere to Marcus Muller's answer + my steps this is how I have fixed it ( all steps via terminal):
Create new directory in my workspace directory and called it libs.
In each one of your projects do: right click > c/C++ Build > Build Steps (tab) and in Post-build steps paste this:
cp ${BuildArtifactFilePrefix}${BuildArtifactFileName} "${WorkspaceDirPath}/libs/"
This code copy the so files directly into your libs directory when you compile your program.
And finally, in your terminal execute this:
export LD_LIBRARY_PATH=/builds/BaseCppProject/libs/
Now you can run your program via terminal.

QtCreator No Executable Specified

I've searched this for a while and haven't found anything answered anywhere:
I have a project in QtCreator that has no compilation errors, and runs fine as a normal C++ project in Eclipse.
However, when I try to run it as a Qt app, it says it could not find an executable and I need to specify one.
As many other sites have suggested, I have searched the directories for the .exe that QtCreator was supposed to make (according to the other sites), but I am yet to find anything.
I'm in no rush, but have spent a long time on this and would like to move on to actually writing the Qt part.
Thanks in advance.
Are you still struggling with the solution ? The most easy solution is, restore default setting by deleting file QtCreator.ini. After that configure project once again by giving build directory path. If you are working on Linux system, run following command to find QtCreator.ini file.
$ locate QtCreator.ini
It will give ouput like this
/home/tan/.config/QtProject/QtCreator.ini
Then delete the file on obtained path using following command
$ sudo rm -f /home/tan/.config/QtProject/QtCreator.ini
Now open project once again and configure with your desired build and run settings.
Upvote if above solution helps you. Btw if I've made any grammatical mistakes, I am sorry for my english. :)
Best luck !!
I'm not sure I understand what you mean by having a QtCreator project and running it in Eclipse or running it as a Qt App but if you are looking for an exe file, QtCreator is probably configured to do shadow builds for your project. This means that build output is sent to a directory outside of your project source directory. If your project is in a directory called MyApp, then look for a directory beside it called MyApp-build-desktop. You should find your executable in there.