I'm attempting to explore MariaDB's source code and thought that the easiest way would be to use a C++ IDE. I used the Bash script debian/autobake-deb.sh bundled in MariaDB to compile the project, then opened it with CLion. Unfortunately it looks like a lot of code is not recognized (even though CMake is bundled with CLion) which prevents me from using autocomplete, function references and such in a lot of places.
For instance when I open libmysqld.c :
There are errors almost every line.
I'm a beginner in C/C++ so I'm not sure what I would have to configure or install to make CLion recognize the symbols better.
edit : Updated screenshot with status bar
Related
I am working with C++ code with ROS2. ROS2 has code style standards and one of the recommended linters is ament_cpplint, which is slightly different from cpplint
Most IDEs/Editors for C++ (Clion, Atom, VS Code, Sublime Text) have plugins for cpplint which will run periodic linter checks as you are editing files. You usually have to set the path to the cpplint executable on your computer. I've tried to set the path to ament_cpplint executable instead but it just won't work. I've tried this with multiple IDEs and plugins by now and none of them will work.
I am not sure what's causing this, Google's cpplint works with IDEs. And I can run $ ament_cpplint from the command line just fine, but I can't get it to work in an IDE.
This might be too late for you, but for others.
You need to pass the path to the cpplint.py executable that is inside the ament_cpplint package.
For ros2 galactic, it is located here:
/opt/ros/galactic/lib/python3.8/site-packages/ament_cpplint/cpplint.py
I try to use Xcode (v.7.3.1) for my C++ project (build system - make), but the experience is quite poor (and it was always like that since old versions like v4 when I started using it) - code completion doesn't work, color syntaxing works oddly (no coloring sometimes, or partially colored code), no "jump-to-definition" functionality, can't switch b/w header/source files with shortcuts. Basically, it's just a text editor where I have to use "Find" and Cmd+Shift+O all the time.
Is this intentional and Xcode will never get any proper support for C++ projects with external build system (make) or am I misconfiguring my project? How can I re-index files in the project? How can I make code completion work?
Thanks,
I believe there is a way to use Xcode with makefiles by adding an external build target, file->new->target->External Build System.
This is an older tutorial but the steps may be worth looking through: http://web.ist.utl.pt/jose.alberto.coelho/mac/MakefilesXcode.pdf
I've never had a problem with the syntax highlighting, but I remember the refactoring support being limited for C++ in some ways.
So, I ended up using this workaround: even though, I use external build system, I create Console Application project in Xcode and choose C++ language in settings. Then, I simply add my source files to the project (just drag folders from the Finder window) and then manually create project targets of type External Build System as I need. I don't use default target and don't use generated main.cpp file at all.
My files get indexed with no problems. I'm also able to debug code as I used to.
I still think Xcode developers should review indexing process for the projects with external build system...
Thanks for all the insights though!
I'm working on a project which has a SQLite database, built by running "sqlite3 [db filename] < [schema filename]" from the Terminal on Mac OS X. I'd like to learn more about the projects system in Xcode, and ideally get it to run this Terminal command automatically when I build the project, additionally copying the created database into the output directory of the C++ project. I've been able to do similar things with Visual Studio before, and I get the impression from the options presented that I can do the same thing in Xcode.
I've added an external build target with the database schema files inside it (so they get source controlled too) and at first it was running with errors that too many arguments were being passed. However, I put single quotes around the arguments and now it runs. But I don't see any output. The file is not generated in the directory I set and I can't find it anywhere else. I was wondering if it took the single quotes as a single argument to sqlite3, but I can't find anything named that either.
I keep finding tutorials such as this one: http://b2cloud.com.au/how-to-guides/precompilation-run-script-in-xcode-4 but it appears that Xcode has changed since they were written and I'm having no luck on 5.0.1. I can't seem to get it to run shell scripts, (hopeful for a workaround) can't find the output of what appear to be successfully run commands, and cannot add Aggregate/External Build Tool projects to the dependencies of my code project, so even if I had it working, it would not rebuild the database with the source code.
I'm more after an outline of the best way to do this in 5.0.1, because I suspect my entire approach may be wrong here.
Thank you for your time.
The first thing I did was to refer to tutorial on FFmpeg site.
I set up MSYS+MinGW64, I cloned all the relevant pre-requisites (i.e OpenSSL, x264, rtmpdump),
I successfully cross-compiled them all. I ran the configure for FFmpeg, and I was able to cross-compile that as well. And my statically linked ffmpeg.exe works to my satisfaction.
In Eclipse I was able to create a project, load up the source code, navigate it, make some changes, even compile and step-through debug. The problem I am having is with the Eclipse design-time error, and I think this is more of an Eclipse/C++ thing than FFmpeg.
For example in ffmpeg.c I find this error "Field 'bitstream_filters' could not be resolved" at this line:
AVBitStreamFilterContext *bsfc = output_streams[i]->bitstream_filters;
that output_streams is of type
OutputStream **output_streams
and when I try to open the declaration for OutputStream Eclipse gives me the option of two locations. Obviously Eclipse is not sure which of these declarations it is, hence the "could not be resolved" error. OutputStream is defined in the following 2 files
ffmpeg.h
libavformat/smoothstreamingenc.c
(hmm nice to know FFmpeg can do smooth streaming...) but anyway the correct definition would of been the one in ffmpeg.h.
So... the whole goal of getting the source into an IDE was so that I could enjoy the benefits of such things like intelisense. What can I do in Eclipse to set some sort of order or rule as to how it should resolve types in cases where the names clash like this?
I am trying to open an existing C++ open-source library in Xcode to publish it with my own modification/additions. The library is Tesseract-OCR, which does not include a .xcodeproj file.
Since Xcode can function as an IDE, is it possible to open a bunch of files as a single project in Xcode? Is there an easy way to produce an Xcode project?
There are several ways you could do it, depending on the level of IDE integration you want. There's no direct way of importing a Makefile-based project into Xcode. You can create a project that builds via the Makefile, but you wouldn't get many of the benefits of using an IDE, since the editor features such as word completion rely on Xcode being able to parse the files in the project. You will be able to use the debugger though. To do this, create a new project and add a custom target with a script build phase that just calls down to Makefile.
If however the project you're building compiles very easily, ie without requiring a lot of macros to be set up, include paths, etc, then it may be simple to just create an empty project and merely add all source files to it. I've used this method extensively for building boost libraries. If this is a configure && make type project then you will probably have to run the configure step first, and ensure any top level config.h files are included in the project.
If the project has a complex makefile then it is likely to be an involved task to create a useful Xcode project
I realise you asked explicitly for Xcode, but in case you were actually trying to solve the problem of "I have existing C++ code which builds and runs fine from the command line, and I'd like to code and debug it in an IDE, what should I do?" my firm recommendation would be to avoid Xcode and go for Eclipse.
The reason is that as far as I can tell, Xcode has no way of ingesting the command line build environment and effectively requires you to recreate the make process inside Xcode from scratch. Fine for tiny projects, but anything with more than a few source files and it quickly becomes painful. Whereas in Eclipse everything is built around Makefiles. So in my case I got to the "step through code with working code completion" in Eclipse a lot quicker vs. never in Xcode. This of course could be because I'm an Xcode noob, but my 2c.
To create an Xcode project from an existing cmake project, you can run cmake -G Xcode. It produces some folders and files apart from the project file, so it might be better to create a folder for it first. For example:
mkdir -p build/xcode
cd build/xcode
cmake -G Xcode ../..
Xcode is a useable IDE for library creation.
Of course a good first step is to see if the one source code will build on its own with configure scripts that are included.
If not, it becomes a question of how many libraries you need to link in.
There are resources online (or at least there used to be) for using Xcode (or perhaps it's forerunner Product builder) for porting Unix projects to Mac.
Good tutorial at: http://www.macresearch.org/tutorial-introducing-xcode-30-organizer
Another good reference is Darwin Ports.
As for doing this on your own. You can build c++ based libraries in XCode. People do that every day. You can even use one of the Xcode templates to get you started.
However, library dev requires more experience with Xcode then say a simple Cocoa "Hello World" app.
The remaining questions will be assuring that the source code's dependencies are already built into the Mac's SDK. (Don't hold your breath for linking to MFC)
It's a general question... So it's a general answer.
In Xcode8,there is "Xcode->file->add files to...",then choose your files.If you want to add several files at a time,press "Cmd" when you are choosing.