How to give file as argument when running CLion Debugger - cmake

I have a c++ program that performs actions with getline(cin,line). When I compile the .c file with g++, I usually just run
g++ lr.cc -o lr
./lr < text
Where text is a file.
However I'm getting an error and would like to debug where in the code the error is being generated (it's a terminate called after throwing an instance of 'char const*'
Aborted (core dumped) error) but I can't seem to get CLion to compile the code and have the text file be a "argument".
I tried editing the arguments to < test, using the full path < /path/to/text/ and also adding the file to the set(SOURCE_FILES) of the CMakeLists.txt.
Any help would be greatly appreciated!

Turns out they don't support it (yet?). Used
std::ifstream in("/path/to/file/to/read");
std::cin.rdbuf(in.rdbuf());
at the beginning of my function that read cin and started the debugger

Related

undefined symbol: __afl_area_ptr when trying to compile Kisak strike

I want to fuzz the map loading feature in counter strike. The source code for csgo got leaked a while back and here is a build which you can compile https://github.com/SwagSoftware/Kisak-Strike . However, when I try to compile it using this command:
AFL_USE_ASAN=1 PERSIST=1 cmake -DCMAKE_BUILD_TYPE=Debug -DUSE_ROCKETUI=ON -DFREETYPE_LIBRARY=/usr/lib/x86_64-linux-gnu/libfreetype.so -DFREETYPE_INCLUDE_DIRS=/usr/include/freetype2/freetype/ -DUSE_KISAK_PHYSICS=ON -DCMAKE_C_COMPILER=/home/cyberhacker/Asioita/Hakkerointi/Counterstrikestuff/aflpp/afl-gcc-fastthing/AFLplusplus/afl-gcc-fast -DCMAKE_CXX_COMPILER=/home/cyberhacker/Asioita/Hakkerointi/Counterstrikestuff/aflpp/afl-gcc-fastthing/AFLplusplus/afl-g++-fast ..
and then when i try to run ./csgo_linux64 , it throws this error:
Failed to load the launcher(bin/linux64/launcher_client.so) (/home/cyberhacker/Asioita/Csgocompile/withjump/game/bin/linux64/libtier0_client.so: undefined symbol: __afl_area_ptr)
I am expecting it to just work as usual (same as with the regular build). It works completely fine when I try to compile it normally with this command:
cmake -DCMAKE_BUILD_TYPE=Debug -DUSE_ROCKETUI=ON -DFREETYPE_LIBRARY=/usr/lib/x86_64-linux-gnu/libfreetype.so -DFREETYPE_INCLUDE_DIRS=/usr/include/freetype2/freetype/ -DUSE_KISAK_PHYSICS=ON -DCMAKE_C_COMPILER=/usr/bin/cc -DCMAKE_CXX_COMPILER=/usr/bin/c++ ..
and then make -j8
I searched a bit and found this: this . In that conversation they say that this error can be cause by compiling with afl-gcc but then linking with normal gcc or ld. However this is not the cause of my problem since I have looked through the cmake log files and the binaries are being linked with afl-g++-fast so this shouldn't be a problem in my case. I read somewhere that the libraries should be statically included, not dynamic but I do not think that it is a necessity. Feel free to look at the Kisak strike source code if you want to (obviously).

How to fix compiling Friday Night Funkin by ninjamuffin 99 from source code but there is no .exe after being compiled?

I tried to compile the source code but there is no .exe https://i.stack.imgur.com/CY4jQ.png
I followed the instructions that is from github https://github.com/ninjamuffin99/Funkin and still it don't fixed it. When I tried to compile the source code in cmd after I typed in lime test windows -debug it shows this
C:/HaxeToolkit/haxe/lib/polymod/git/polymod/format/XMLMerge.hx:189: characters 10-23 : Warning : This typedef is deprecated in favor of haxe.xml.Access
C:/HaxeToolkit/haxe/lib/polymod/git/polymod/format/XMLMerge.hx:189: characters 30-43 : Warning : This typedef is deprecated in favor of haxe.xml.Access
source/PlayState.hx:299: characters 3-39 : Warning : `FlxCamera.defaultCameras` is deprecated, use `FlxG.cameras.setDefaultDrawTarget` instead
C:\Users\username\Downloads\FNF MODDING\Kade-Engine-master\Kade-Engine-master\export\debug\windows\obj>setlocal enabledelayedexpansion
Warning: Could not find Visual Studio 2017 VsDevCmd
Missing HXCPP_VARS
Error: Could not automatically setup MSVC
can you help me please?
Googling "Could not automatically setup MSVC" the most common error seems to be failing to restart your PC after installing VS.
I've found that VS has a separate shortcut for "Visual Studio Command Prompt", are you using that rather than a generic command window?

Custom build command does not work with `cargo publish` because CMake says the path would exceed CMAKE_OBJECT_PATH_MAX

My project can be built and run locally, but when running cargo publish I get an error:
PS C:\Users\jonat\Projects\vulkano_blas> cargo publish
Updating crates.io index
Packaging vulkano_blas v0.1.0 (C:\Users\jonat\Projects\vulkano_blas)
Verifying vulkano_blas v0.1.0 (C:\Users\jonat\Projects\vulkano_blas)
Compiling autocfg v1.0.0
Compiling lazy_static v1.4.0
Compiling maybe-uninit v2.0.0
Compiling libc v0.2.73
Compiling cfg-if v0.1.10
Compiling cc v1.0.58
Compiling proc-macro2 v1.0.19
Compiling scopeguard v1.1.0
Compiling unicode-xid v0.2.1
Compiling syn v1.0.35
Compiling vulkano v0.19.0
Compiling either v1.5.3
Compiling smallvec v1.4.1
Compiling vk-sys v0.5.2
Compiling half v1.6.0
Compiling fnv v1.0.7
Compiling itertools v0.9.0
Compiling crossbeam-utils v0.7.2
Compiling memoffset v0.5.5
Compiling crossbeam-epoch v0.8.2
Compiling shared_library v0.1.9
Compiling cmake v0.1.44
Compiling quote v1.0.7
Compiling shaderc-sys v0.6.2
Compiling crossbeam-queue v0.2.3
Compiling crossbeam-channel v0.4.3
Compiling crossbeam-deque v0.7.3
Compiling crossbeam v0.7.3
The following warnings were emitted during compilation:
warning: System installed library not found. Falling back to build from source
error: failed to verify package tarball
Caused by:
failed to run custom build command for `shaderc-sys v0.6.2`
Middle part removed due to its size
--- stderr
CMake Warning in spirv-tools/source/reduce/CMakeLists.txt:
The object file directory
C:/Users/jonat/Projects/vulkano_blas/target/package/vulkano_blas-0.1.0/target/debug/build/shaderc-sys-81aff4f7b9007197/out/build/spirv-tools/source/reduce/CMakeFiles/SPIRV-Tools-reduce.dir/./
has 191 characters. The maximum full path to an object file is 250
characters (see CMAKE_OBJECT_PATH_MAX). Object file
remove_unreferenced_instruction_reduction_opportunity_finder.cpp.obj
cannot be safely placed under this directory. The build may not work
correctly.
CMake Warning:
Manually-specified variables were not used by the project:
CMAKE_ASM_COMPILER
CMAKE_ASM_FLAGS
thread 'main' panicked at '
command did not execute successfully, got: exit code: 1
build script failed, must exit now', C:\Users\jonat\.cargo\registry\src\github.com-1ecc6299db9ec823\cmake-0.1.44\src\lib.rs:885:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Where does the problem lie? And how could I approach fixing this?
As the error says, the path is too long for CMake / Windows.
You might try to enable Long Paths support in Windows, or put your project in a shallower path.
Building in a shallower directory worked for me:
#.cargo/config.toml
[build]
# fixes CMAKE_OBJECT_PATH_MAX
target-dir = "C:/temp/crate_name"
While this can also be done with a compiler flag, that is not recommended because cargo clean etc will not work as expected.
A side note, Ive had some runtime linker errors using this method with embuild and an esp32. The solution there was to move the entire repo closer to root and keep the default target dir, its a bummer but no two ways about it.

ANTRL4: TestRig error

I am just trying to get ANTLR to run following those instructions: http://www.antlr.org/wiki/display/ANTLR4/Getting+Started+with+ANTLR+v4
The grammar is translated into code, but when I want to call TestRig, I'm getting the error "Can't load Hello as lexer or parser".
TestRig is located in file C:\bin\grun.cmd and contains this command
java -cp .;C:\LIBS\Java\ANTLR\antlr-4.1-complete.jar
org.antlr.v4.runtime.misc.TestRig %1 %2
Is anything wrong with that?
When I try to start TestRig from the ANTLWorks IDE I'm receiving warnings like:
warning: Supported source version 'RELEASE_6' from annotation
processor
'org.netbeans.modules.openide.modules.PatchedPublicProcessor' less
than -source '1.7'
warning: Supported source version 'RELEASE_6' from
annotation processor
'org.netbeans.modules.openide.util.ServiceProviderProcessor' less than
-source '1.7'
warning: Supported source version 'RELEASE_6' from annotation processor
'org.netbeans.modules.openide.util.NamedServiceProcessor' less than
-source '1.7'
warning: Supported source version 'RELEASE_6' from annotation processor
'org.netbeans.modules.openide.util.NbBundleProcessor' less than
-source '1.7'
and errors like:
line 1:7 token recognition error at: ' '
...........
line 1:0 missing 'hello' at 'grammar'
On Linux I'm experiencing another problem with ANTLRWorks2:
For whatever reason the menu bar doesn't work so that it's impossible to select anything from there. Anyway, clicking on an icon below the menu bar works.
What might be wrong here? Thanks for any help.
Almost a year late on this but in case others have the issue...
I am guessing you named your grammar file 'hello' instead of 'Hello' or you didn't copy the contents correctly.
https://theantlrguy.atlassian.net/wiki/display/ANTLR4/Getting+Started+with+ANTLR+v4
The warnings about 'RELEASE_6' are supposedly harmless according to this bug report.
https://netbeans.org/bugzilla/show_bug.cgi?id=210286
I am still getting these warnings in ANTLRWorks2.1. According to the final post it may be fixed in the NetBeans plugin. However, as far as I can tell this plugin has been recently broken.
I can't help you with IDE issues on Linux.

FreeType2 Crash on FT_Init_FreeType

I'm currently trying to learn how to use the FreeType2 library for drawing fonts with OpenGL. However, when I start the program it immediately crashes with the following error: "(Can't correctly start the application (0xc000007b))"
Commenting the FT_Init_FreeType removes the error and my game starts just fine. I'm wondering if it's my code or has something to do with loading the dll file.
My code:
#include "SpaceGame.h"
#include <ft2build.h>
#include FT_FREETYPE_H
//Freetype test
FT_Library library;
Game::Game(int Width, int Height)
{
//Freetype
FT_Error error = FT_Init_FreeType(&library);
if(error)
{
cout << "Error occured during FT initialisation" << endl;
}
And my current use of the FreeType2 files.
Inside my bin folder (where debug .exe is located) is: freetype6.dll, libfreetype.dll.a, libfreetype-6.dll.
In Code::Blocks, I've linked to the lib and include folder of the FreeType 2.3.5.1 version.
And included a compiler flag: -lfreetype
My program starts perfectly fine if I comment out the FT_Init function which means the includes, and library files should be fine.
For people who might stumble upon the same problem and can't find it out. I'll post my solution:
It seemed the error code ussualy comes up with loading .dll's. I used process explorer to check if my program was actually loading the correct .dll but it wasn't. I deleted my FreeType dll's and replaced them with a version compiled specifically for my version of windows to make sure I have the right dll's. Replacing the old one with the new one helped.
I had the same problem, turnes out that I had forgotten to copy over the zlib1.dll file.
I had the same "cant correctly start" error. It turned out my program was finding a zlib1.dll in something like c:\intel\wifi\bin, that DependencyWalker flagged as AMD64 (my PC is Win7 64, but my app is 32 bits.) It was fixed when I copied freeType's zlib1.dll to SysWOW64. Tough nut to crack!