Running Clang-query on objective-c files that import Foundation - c++

I am trying to use clang-query to run matches against obj-c files that import Foundation but its not working, After building clang-query by moving it to the tools/extra folder, I run it using this command:
./clang-query MyClass.m -- -extra-arg-before "-isysroot/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk"
But I'm getting this error:
fatal error: 'stdarg.h' file not found
#include <stdarg.h>
How should I be running clang-query to analyse my objective-c sources?

After doing more research I found out that the right approach is to use libTooling based tools. As stated in their documentation:
Clang Tooling needs a compilation database to figure out specific build options for each file. Currently it can create a compilation database from the compile_commands.json file
For Xcode projects, this file can be generated like this:
xcodebuild -project PROJECT_NAME.xcodeproj | xcpretty -r json-compilation-database --output compile_commands.json
you will need to install the xcpretty gem. (gem install xcpretty)
Source: https://clang.llvm.org/docs/HowToSetupToolingForLLVM.html
UPDATE:
IF like me, you are having issues with the compile_commands.json file generated from xcodebuild logs, just pass this commands to your binary:
-mios-simulator-version-min=10.0 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk -isystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/10.00/include -I/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1 -I/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/usr/include -F/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/Frameworks
You might need to update some of the parameters based on your system configuration but this is working fine for me currently.

Related

Problem with GRPC generating client and server code on Windows 10 after installing with VCPKG

I am having problems generating client and server code for a GRPC service. I'm adapting the instructions at grpc.io.
There is a single protobuf file test_interface.proto defining my service and I've tried to build it with both of the following commands, run in the same path as this file:
protoc -I . --grpc_out=. --plugin=protoc-gen-grpc="C:\vcpkg\packages\grpc_x64-windows\tools\grpc\grpc_cpp_plugin" ./test_interface.proto
protoc -I . --grpc_out=. --plugin=protoc-gen-grpc=grpc_cpp_plugin ./test_interface.proto
Both of which result in the error:
--grpc_out: protoc-gen-grpc: The system cannot find the file specified.
I'm on Windows 10 and installed grpc v1.33.1 using vcpkg. This installs the development dependencies, but does not add their binaries to the system path. I've manually added the locations of protoc and grpc_cpp_plugin to the Path.
It's not clear to me which file it is failing to find, there were some syntax errors picked up earlier in test_interface.proto So I know this file is being opened okay. I can also run grpc_cpp_plugin from the command line without any problems.
Does anyone know why this is failing to build the client and server code?
make sure to add .exe to your plugin path like so: C:\vcpkg\packages\grpc_x64-windows\tools\grpc\grpc_cpp_plugin.exe
There's a note about this in our docs here:
https://developers.google.com/protocol-buffers/docs/reference/cpp/google.protobuf.compiler.plugin

Can't download json schema using gradlew command

I can't figure out how to use the gradlew command to convert my GraphQL schema into a JSON file as it is specified in the documentation.
I opened CMD in my project folder, ran the gradlew command once, and it gave me this error:
Project 'module' not found in root project gradlew
I created a module inside my project with the name "module" and now it's throwing the following error:
Task 'downloadApolloSchema' not found in project ':module'.
I've already added all the dependencies to the latest version (2.0.0 as of the time of posting) so I'm clueless as to why this is happening. I've already searched the web and found nothing about this...
This is the command I'm trying to issue in the CMD:
C:\Users\myuser\AndroidStudioProjects\GraphQLApp\app>..\gradlew :module:downloadApolloSchema -Pcom.apollographql.apollo.endpoint=https://graphql-udemy-android.herokuapp.com/graphql -Pcom.apollographql.apollo.schema=src/main/graphql/com/example/schema.json
I have to go up one directory (..\) since the gradlew command is in the above my app folder.
I'm on Windows, and my Gradle version is 6.4.
You just change ./gradlew to .\gradlew
Open the root terminal
Paste the code below and ENTER!
.\gradlew downloadApolloSchema --endpoint=https://Your Endpoint/graphql --schema=app/src/main/graphql/com/example/Your Path/schema.json
Have a good days!
Sorry about that, the module part was mostly a placeholder for the gradle module where you apply the com.apollographql.apollo plugin. You can ignore it and gradle will find the appropriate task:
./gradlew downloadApolloSchema
This has been updated in the project README as well.
For windows i used
.\gradlew downloadApolloSchema --endpoint="https://rickandmortyapi.com/graphql" --schema=app/src/main/graphql/GetRepositories.json
NOTICE I used:
.\ instead of ./

Can't find files of cxxtest when I'm trying to run compiled file

I started writing a small project on C++. I just wanted to develop using TDD because in Java I always do that. I faced a problem that using any libraries and so on is a bit easier in Java IDEs and tools (like maven and so on). But it's not exactly topic I'm talking about.
I found cxxtest framework and decided to add one into my project.
I added the latest version of sources exactly into my test package in project, then I write simple test, and then I ran preprocessor (using python) by "python cxxtestgen --error-printer -o ../runner.cpp ../../testSample.h" from cxxtest-4.4/bin folder.
After that I got the runner.cpp file into cxxtest-4.4 folder. I tried to run that using command "g++ -o runner runner.cpp" in suitable place...and got the following message:
bash-3.2$ g++ -o runner runner.cpp
runner.cpp:8:10: error: 'cxxtest/TestListener.h' file not found with <angled> include; use "quotes" instead
#include <cxxtest/TestListener.h>
^~~~~~~~~~~~~~~~~~~~~~~~
"cxxtest/TestListener.h"
In file included from runner.cpp:8:
./cxxtest/TestListener.h:24:10: fatal error: 'cxxtest/Descriptions.h' file not found
#include <cxxtest/Descriptions.h>
^~~~~~~~~~~~~~~~~~~~~~~~
Here I put my project structure:
The project structure
It seems very strange because I've never seen the same troubles before. And it's not able to find same issues.
So, would be great if somebody told my even right direction to fix this problem. Let me know If you need something else to make more clear understanding of this problem (code, any technical info, etc)
Some info: I'm using CLion on macOS, it means I have CMake (version 3.6 at least), I have both perl and python on my mac. Project with C++14 language version.

Vim, Help getting YCM working for c++

I am trying to install YouCompleteMe Plugin for VIM. This what I did so far:
I am using Vundle so I added the Plugin to my .vimc
I executed install.py --clang-completer
I added "let g:ycm_global_ycm_extra_conf = '.vim/bundle/YouCompleteMe/third_party/ycmd/cpp/ycm/.ycm_extra_conf.py" to my vimrc
I tried testing it on very simple helloworld program however I am not getting any useful suggestions. For instance, when I type 'std::' I dont get any intelisense.
I confirmed that YCM server is running and there are no errors in the logs.
Interestingly when I execute 'ValueError: Still no compile flags, no completions yet.'
You have to provide a compilation database (easier) or provide compile flags manually.
If you are not using CMake chanches are that you will like Bear.
With bear just clean your project, cd to the build directory and use it to generate the compile_commands.json file. E.g.
$ cd /path/to/your/project/build/directory
$ bear make
$ cp compile_commands.json /path/to/your/project/source/directory

Building log4cxx with APR

I need to build the log4cxx library on a SuSE linux system where I am not root. The package manager, zypper, apparently does not know about log4cxx.
I download log4cxx and try to build with autotools
./configure
checking for APR... no
configure: error: APR could not be located. Please use the --with-apr option.
I then search for libapr:
find / -name libapr*
/usr/share/doc/packages/libapr-util1
/usr/share/doc/packages/libapr1
/usr/lib64/libaprutil-1.so.0.3.12
/usr/lib64/libapr-1.so.0.4.5
/usr/lib64/libaprutil-1.so.0
/usr/lib64/libapr-1.so.0
So I try
./configure --with-apr=/usr/lib64/libapr-1.so.0
configure: error: the --with-apr parameter is incorrect. It must specify an install prefix, a build directory, or an apr-config file.
The same for --with-apr=/usr/lib64/libapr-1.so.0.4.5 and --with-apr=/usr/lib64/.
Which file does ./configure look for? What does --with-apr expect? Is one of the two *.so.* files the needed library?
You'll probably want to install libapr1-devel so that you can compile against it. Then try re-running ./configure.
I ran into the same issue, I think you're using the source code off of appache's site which I beleive is outdated. This issue has been fixed in the SVN trunk several years ago (lolol, I guess right around the time this question was asked).
Just pull the svn trunk's source and compile it:
svn checkout http://svn.apache.org/repos/asf/incubator/log4cxx/trunk apache-log4cxx
./autogen.sh
./configure
make
make check
sudo make install
On software.opensuse.org someone has packages built for recent versions of openSUSE as well as SLE at liblog4cxx10. Maybe that'll work for you instead of building your own.
MichaelGoren is right.
There is multiple ".h" file missing.
So you have to add them before launching make.
sed -i '1i#include <string.h>\n' src/main/cpp/inputstreamreader.cpp
sed -i '1i#include <string.h>\n' src/main/cpp/socketoutputstream.cpp
sed -i '1i#include <string.h>\n' src/examples/cpp/console.cpp
sed -i '1i#include <stdio.h>\n' src/examples/cpp/console.cpp
I bumped into the same problem on 3.3.4-5.fc17.x86_64 and resolved it by including the appropriate H files to the CPP files reported by the make utility.
In my case I should run the make utility 3 times each time getting a new error and fixing it by adding the appropriate include H to the reported CPP file.
The main idea is as following:
1) Check by running the man utility, where the function mentioned in the error defined.
For example, man memmove says that it is defined in the string.h header file.
2) Add the appropriate include file to the CPP file.
For example, the make utility complains that inputstreamreader.cpp does not find the memmove function. Open the inputstreamreader.cpp file and add string.h to its header files.
3) Run the make utility until the log4cxx is compiled without errors.