Build .vcxproj on Linux using xbuild - c

I want to run a simple C script on Ubuntu like this:
xbuild HelloWorld.vcxproj
When I run the script, I get this error:
HelloWorld.vcxproj: error :
/opt/jetbrains/TeamCity/buildAgent/work/d4407e37ceba8427/Hel‌​loWorld/HelloWorld.v‌​cxproj:
/opt/jetbrains/TeamCity/buildAgent/work/d4407e37ceba8427/Hel‌​loWorld/HelloWorld.v‌​cxproj
could not import "$(VCTargetsPath)\Microsoft.Cpp.Default.props"
This is the script:
#include <stdio.h>
int main(void)
{
printf("Hello world\n");
}

There is a project GCCBuild which you can use to build vcxproj files in Linux. It simple uses same structure of vcxproj but uses GCC to compile and build. There are multiple examples there too.

Related

fatal error: studio.h: no such file or directory

I'm trying to learn how to program in C.
I'm simultaneously learning C, C++, & Java. I have also coded in html and javascript successfully making rich websites.
I'm following video lessons on skillshare. Through VirtualBox I've set up a ubuntu installation, created lesson001.c, and attempted to compile it by entering "gcc lesson001.c"
The program:
#include <studio.h>
int main(){
printf("hello, world!\n");
return 0;
}
The error:
lesson001.c:1:10 fatal error: studio.h: no such file or directory.
The instructor is walking through the coding lesson on a pre-configured linux system, so he does have the same errors. It is frustrating that a comprehensive paid lesson set does not include critical setup parameters.
additional info: "gcc -v" returns about 20 lines of information on gcc 9.3.0, so I believe it is installed correctly.
Thank you
Change the #include <studio.h> declaration to #include <stdio.h>. A header file named studio.h does not exist in the standard library.
stdio stands for "standard input/output," and has nothing to do with "studio"! 😀
It should be stdio instead of studio.
stdio stands for Standard Input Output
Correctly formatted code :
#include <stdio.h>
int main(){
printf("hello, world!\n");
return 0;
}

how can i fix windows c_api error with tensorflow.dll?

I tried to compile on windows c program with tenserflow c api and tenserflow.dll from https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-cpu-windows-x86_64-1.12.0.zip founded on https://www.tensorflow.org/install/lang_c.
This example:
#include <stdio.h>
#include <tensorflow/c/c_api.h>
int main() {
printf("Hello from TensorFlow C library version %s\n", TF_Version());
return 0;
}
Compiling is success, but when i have run it, i recieved a mistake that libtenserflow.so not found. Its look like that tensorfow,dll from https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-cpu-windows-x86_64-1.12.0.zip was builded with some mistakes for windows sistem, becaurse libtensorflow.so is a target for Linux.
Can you explain or fix this?
I guess it looks for tensorflow.so because you were using GCC tools on VS Code's WSL mode (or other IDEs). But in order to load DLL you need to have Visual Studio.
Here's a simple process to run the Tensorflow for C demo:
Create a new project in Visual Studio;
Configure the project properties(assume the Tensorflow path is C:\tensorflow\; replace it with yours):
C/C++ > General > Additional Include Directories, add "C:\tensorflow\include\"
Debugging > Environment, add "PATH=C:\tensorflow\lib\;%PATH%"
Don't forget the "PATH=" before your tensorflow.dll path.
Compile and run.
You may also add the Tensorflow path to system environment (replace C:\tensorflow\ with your path):
SET PATH=%PATH%;C:\tensorflow\lib\
P.S. If you don't like the Visual Studio IDE and prefer to use Tensorflow with command line mode, try Bazel for Windows instead.

Cannot use C libraries compiled from Go code using "Go build"

I am trying to get a minimal example of using Go code in C to work, such as this. I am struggling with the following compilation error message:
ld: warning: ignoring file
/Users/username/gocode/src/example/example.dylib, file was built for
archive which is not the architecture being linked (x86_64):
/Users/username/gocode/src/example/example.dylib
My attempt is the following. I have a simple Go package in a file main.go:
package example
import "C"
//export GoEcho
func GoEcho(s *C.char) string {
return C.GoString(s)
}
func main() {}
which I then compile using either
go build -buildmode=c-archive -o example.dylib main.go
or
go build -buildmode=c-shared -o example.dylib main.go
or
GOARCH=amd64 go build -buildmode=c-shared -o LibraryLinkExamples.dylib main.go
The operating system is OS X 10.11 and the the Go version is, as go version puts it, go1.9 darwin/amd64.
The C code I'm using is the following:
#include "example.h"
#include <stdio.h>
int main(int argc, char const *argv[])
{
GoString res = GoEcho("test");
printf("%.*s\n", (int)res.n, res.p);
return 0;
}
I don't understand why I am getting the "which is not the architecture being linked (x86_64)" error message when I am building the library and using it on the same operating system, even the computer? What can explain this?
Update
In the official documentation here it says:
amd64 (also known as x86-64)
meaning it should be x86-64 compatible with this setting. That it isn't is possibly a bug in go build?

Run Plain C Project in Qt Creator

I created a plain c project in qt creator using
File->New file or Project->Non Qt Projects->Plain C Project
main.c
#include <stdio.h>
int main(void)
{
printf("Hello World!\n");
return 0;
}
test.pro
TEMPLATE = app
CONFIG += console
CONFIG -= qt
SOURCES += main.c
I build the project using Ctrl+B which was successful. But I am not able to run the project with Ctrl+R.
I earlier used to run the following command to compile and run c program
gcc main.c
./a.out
But Now I am not able to get how to run c program in qt creator.
I am new to Qt Creator. Please Help
Have you set the run settings of your project correctly ?
Make sure to set them like this https://doc.qt.io/qtcreator/creator-run-settings.html
edit: updated link for recent QtCreator version
Seems like the working directory or executable path are missing.
Is there any output given like "could not execute ./a.out : No such file or directory" ?

Importing CUnit sources

i'm having a problem to use Unit test in C, i've tried to install CUnit in my computer and after include the lib.
i've followed steeps to install the CUnit:
1 - download the sources
2 - configure it using "./configure --prefix='/lib' "
3 - make (only make)
4 - sudo make install
and this is my test source file, it's not making tests, but i can't compile this, i got this error before "CUnit.h: No such file or directory":
#include "CUnit.h"
#include <stdlib.h>
#include <stdio.h>
int main(){
print("Hello");
return 0;
}
I want to know, how can i install CUnit to use in my test source files!
Thanks in advance.
EDIT
HAHA, i got this!
i just run configure without parameters, like that:
"./configure"
As shown in the code example you should use something like this :
#include <CUnit/CUnit.h>
because every CUnit includes are located in a CUnit subdirectory (in general in /usr/local/include/CUnit)
What about adding -I/lib/include flag to include header files installed in /lib/include/CUnit and -lcunit -L/lib/CUnit/lib for linking with the installed libraries?
gcc test_file_source.c -I/lib/include -lcunit -L/lib/CUnit/lib -o testing

Resources