Here is the instructions: https://github.com/json-c/json-c/blob/master/README.md#build-instructions--
This is the first time I've ever built from source.
I'm on Windows 10 and I used CMake to build.
I did this and it all worked fine:
$ git clone https://github.com/json-c/json-c.git
$ mkdir json-c-build
$ cd json-c-build
$ cmake ../json-c
But I don't understand this part:
$ make
$ make test
$ make USE_VALGRIND=0 test # optionally skip using valgrind
$ make install
Can someone explain to me what these lines do?
I installed mingw32-make but when I run mingw32-make on its own like in the this tutorial it just says:
mingw32-make: *** No targets specified and no makefile found. Stop.
Do I need to create a Makefile? It doesn't say anywhere in the installation notes to do this but I cannot get past this step, what am I doing wrong?
Related
I'm trying to set up CMake for a project I'm working on, and I'm first trying to compile a simple Hello World program in C. I'm using Windows 10 with MSYS2. If I invoke the compiler (GCC) directly in Bash, it compiles fine without warnings or errors and gives an executable as output which prints "Hello, world!" exactly as expected. My problem comes in when I try to use CMake to compile my project. When I run cmake -G Ninja .. to compile my project, it throws this error:
CMake Error at C:/msys64/mingw64/share/cmake-3.15/Modules/CMakeTestCCompiler.cmake:60 (message):
The C compiler
"C:/msys64/mingw64/bin/cc.exe"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: C:/Users/dylanweber/Documents/C-Projects/webapp/build/CMakeFiles/CMakeTmp
Run Build Command(s):C:/msys64/usr/bin/ninja.exe cmTC_45340 && [1/2] Building C object CMakeFiles/cmTC_45340.dir/testCCompiler.c.obj
FAILED: CMakeFiles/cmTC_45340.dir/testCCompiler.c.obj
C:\msys64\mingw64\bin\cc.exe -o CMakeFiles/cmTC_45340.dir/testCCompiler.c.obj -c testCCompiler.c
/bin/sh: C:msys64mingw64bincc.exe: command not found
ninja: build stopped: subcommand failed.
Notice how it mentions C:msys64mingw64bingcc.exe... there must be some kind of path delineation problem but I've tried setting the CC environmental variable to C:\\msys64\\mingw64\\bin\\gcc.exe and C:/msys64/mingw64/bin/gcc.exe. I have been clearing the CMake caches between runs.
Here is my CMakeLists.txt file:
cmake_minimum_required(VERSION 3.15)
project(webapp)
set(CMAKE_BINARY_DIR ${CMAKE_SOURCE_DIR}/build)
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR})
set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR})
file(GLOB SOURCES "main/*.c")
add_executable(webapp ${SOURCES})
My code is in a "main" folder which is currently just one "main.c" file, in addition to a build directory used to keep all the temporary files in. The most frustrating part is that CMake was just working an hour ago, and I didn't change anything. What can I do to fix this problem?
The solution was not only installing the MinGW64 version of CMake, but also the MinGW64 version of Ninja as well. Since they have different pathing schemes compared to MSYS, they didn't play well together until they were both on the same POSIX-like platform.
I'm following the steps of the online book: "Learn C The Hard Way", and since I'm using Windows 7, I've installed Cygwin to use the Linux commands. But I'm facing a problem just on the first exercise of the book. I'm supposed to put the following command on the shell:
$ make ex1
After creating a ex1.c file on the folder. The command should give me:
cc ex1.c -o ex1
But instead, I'm getting the following message:
$ make ex1
cc ex1.c -o ex1
process_begin: CreateProcess(NULL, cc ex1.c -o ex1, ...) failed.
make (e=2): The system cannot find the specified file.
make: *** [ex1] Error 2
What's wrong?
First of all you should know that you should be running the command in the same directory where the file is. In cygwin, first you will have to locate to the folder in which the file is present, then you can run these make commands. Better since you are using Windows. You should better use any other windows based client for C. But if I were at your place. I would have installed a virtual Linux environment on my local windows computer and would have worked on that. You should try that once. Linux Terminal gives a lot of power to the developer. There are a lot of things which you can do on a terminal which is not supported by cygwin. For compiling C programs on Cygwin, I believe you should check if it supports compiler commands or not. :)
Make is reporting that it can not find cc.
cc is a link to gcc, and it belongs to gcc-core.
$ cygcheck -f /usr/bin/cc
gcc-core-5.4.0-1
To verify if the package is correctly installed
$ cygcheck -c gcc-core
Cygwin Package Information
Package Version Status
gcc-core 5.4.0-1 OK
If, as likely, the package is missing, you need to install it with the cygwin setup.
I am working on a system on which I am a non-root user.
While trying to install gcc 5.1 in a custom directory as the present shared version of gcc isn't working for postgresql installation, I started out by
wget gcc 5.1.
After unzipping the folder, ran the commands below:
cd /seq/genome_portal/lib
mkdir bld
mkdir gcc
cd bld
/seq/genome_portal/lib/gcc-5.1/configure --prefix=/seq/genome_portal/lib/gcc
However config.log still shows this error:
/../../redhat_6_x86_64/pkgs/gcc_4.9.0/libexec/gcc/x86_64-redhat-linux/4.9.0/cc1: error while loading shared libraries: libmpfr.so.4: cannot open shared object file: No such file or directory
The prerequisites that come after
./contrib/download_prerequisites
are gmp,mpfr and mpc. I started with gmp and ended up in the same error as above. I somehow need to tell these programs that I do not want to use the existing gcc.
But I get the same error as mentioned before. Any advice as to how I can proceed to install it?
Building a compiler is much more complicated that building a straightforward utility; just running configure is not enough.
Primarily, you need to read the instructions; they are provided in the GCC source directory in the INSTALL subdirectory. They are in HTML so point your browser at it.
I know you didn't do this yet because the step on configuration makes very clear you should be using an out-of-source configuration; e.g., something like:
mkdir ../bld
cd ../bld
../gcc-5.1/configure ...
rather than running ./configure.
Regarding the missing dependencies, there's a "prerequisites" section in the docs. To get MPFR and other helpful things you can run:
cd gcc-5.1
./contrib/download_prerequisites
ETA: This should work:
rm -rf newgcc
mkdir newgcc
cd newgcc
tar xzf gcc-5.1.tar.gz
cd gcc-5.1
./contrib/download_prerequisites
mkdir ../bld
cd ../bld
../gcc-5.1/configure <configopts>
make -j8
make install
(or whatever -j you prefer).
I'm using gperftools for analysing my C code. An as a result I can't analyze the profile file using pprof application.
$ gcc -g prog.c -o prog -lprofiler
$ export CPUPROFILE=info.prof
$ ./prog
Inside main()
Inside func1
Inside new_func1()
Inside func2
PROFILE: interrupts/evictions/bytes = 1133/0/300
$ ls
info.prof prog prog.c
$ ls -lah info.prof
-rw-rw-r-- 1 mm mm 2.6K Jun 6 09:36 info.prof
$ pprof info.prof prog
Reading Profile files in profile.*
Error: Could not open profile.0.0.0: No such file or directory
profile.ftab: No such file or directory
$
What do I wrong? What's the profile.ftab file?
You're not using the correct 'pprof' tool. In particular, you're using http://www.cs.uoregon.edu/research/tau/docs/newguide/bk03ch01s08.html (which is totally unrelated), whereas you need the one here: https://code.google.com/p/gperftools/ I had the same issue and solved the problem by downloading the gperftools' source, building it, and using ./src/pprof
I just ran into this and I think it is worth mentioning how to deal with this in recent versions of Ubuntu (18.04 specifically).
When one tries to run the pprof command, the system suggests installing the tau package:
Command 'pprof' not found, but can be installed with:
sudo apt install tau
Do not install that package though, because it is entirely unrelated as David Carney pointed out in his answer. Install the google-perftools package instead, but be aware that the executable in it is called google-pprof instead of just pprof.
You installed the wrong pprof.
If you already have golang installed. You can install pprof using go.
Just do,
go get github.com/google/pprof
Also install graphviz if you want to generate PDFs using
sudo apt-get install graphviz
I am new to VS development and Cmake.
I have used CMake-GUI to generate a visual studio solution and am able to build it successfully.
However, our code has now reached a stage where we can finally build & link into a binary. With multiple people checking in code, we want to do a nightly build and so I was thinking of writing a batch file for this.
However, I am trying to invoke cmake from command line and am running into issues.
In cmake-gui, in order to configure, I provide two values
Path of my source code
Path where binaries will be generated
However, when I try to run the same over command line (using the following command)
cmake -G "NMake Makefiles" -D CMAKE_SOURCE_DIR="D:\source_code" -D CMAKE_BINARY_DIR="D:\source_code\build\gen\host"
CMake throws up an eror : The source directory "D:\" is a file not a directory.
I tried the following variations too without any luck
cmake -G "NMake Makefiles" -D PROJECT_SOURCE_DIR="D:\source_code" -D PROJECT_BINARY_DIR="D:\source_code\build\gen
Can someone please guide me to the correct syntax.
Thanks in advance
You shouldn't try and set any of these variables on the command line. They're automatically set by CMake the first time it reads the CMakeLists.txt.
Instead, you should run the CMake command from within the binary dir, and pass the path to the directory containing the top-level CMakeLists.txt. So something like:
cd D:\source_code\build\gen\host
cmake -G"NMake Makefiles" D:\source_code
By the way, CMake's command line parsing isn't great (e.g. see this answer). I'd recommend avoiding leaving spaces after -D arguments.
Try this
Remove space between -D and parameter
cmake -G "NMake Makefiles" -DCMAKE_SOURCE_DIR="D:\source_code" -DCMAKE_BINARY_DIR="D:\source_code\build\gen\host"
In my project, We used a CMake-GUI. But I created a shell script file to avoid repeatedly fill up the entries.
Sample gist is as follows.
cd <DIRECTORY_TO_BUILD> && <CMAKE-INSTALLATION-PATH>/bin/cmake.exe --build= "<BUILDSOURCE-PATH> -DQt5Widgets_DIR:PATH=C:/Qt/5.12.0/msvc2017/lib/cmake/Qt5Widgets
I have started with cd else the script will create the build folder from where the script is run.