In Eclipse for Java, library classes are auto-imported in the class file
and it also prompts to choose which library if 2 library classes have the same method .
Is there a similar option for Eclipse CDT to automatically include iostream, math.h, stdio.h. Or do I need to type it out for every source file.
My compiler is Linux GCC.
Eclipse CDT does have the option to automatically add and managed the #includes for you.
To do so, select Source menu -> Organize Includes, or if you prefer the keyboard shortcut, Ctrl+Shift+O (letter o).
The settings that control what the organize includes does is controlled from preferences -> C/C++ -> Code Style -> Organize Includes, as shown in this screenshot:
If you have a symbol that is in multiple include files, you will be prompted. In this screenshot I have b with no #include already covering it, and two includes in my project that define the symbol (works with system includes too):
Related
I'm porting a C project compiled on linux to an arm platform using Eclipse Luna on Ubuntu 16.04
When I switch from CC=gcc to CC=arm-none-eabi in the Makefile I get a lot of missing headers and that's ok, that's what the porting job is about.
What bothers me is that when I CTRL-click on a symbol Eclipse doesn't open the corresponding file for the arm toolchain. For instance if I CTRL-click on <time.h> it does NOT open:
/media/BUILDS/arm_gcc493/arm-none-eabi/include/time.h
but instead it always reverts to its linux system counterpart, in this case
/usr/include/i386-linux-gnu/time.h
because that's where gcc would look for but I'm compiling with arm-none-eabi-gcc instead!
I don't want Eclipse to do that because debugging gets really confusing. If I have a problem with the header/source I'm actually trying to compile with, I want Eclipse to open me that file and not the default system one. I fiddled with Project Properties and Eclipse Preferences but with no luck.
Even worse, whenever <sys/socket.h> is included I get an error because the arm toolchain does not have socket.h but if I CTRL-click on it Eclipse takes me to /usr/include/i386-linux-gnu/sys/socket.h
I dont' want that, if the header needed for compilation is not there, it's just not there. I don't want Eclipse to show me other stuff, how do I do that?
The project was created importing into the workspace "Existing Code as Makefile Project" under C/C++
Thank you very much
EDIT:
I did the proper thing and started from scratch creating a project for the Cross ARM GCC Toolchain (with the proper plug-in). My mistake was creating a "Linux GCC" Project and pretending that Eclipse understood what I was trying to achieve just by launching a different "make" command. If, however, you can't restart from scratch, the accepted solution instructs you on how to fix the situation manually.
To resolve this situation you need to update the Preprocessor Include Paths, Macros, etc. setting to use your custom-prefix GCC.
To make the change:
Open Project Properties (Right-click on project and choose Properties)
In C/C++ General -> Preprocessor Include Paths, Macros, etc., choose Providers tab
Select CDT GCC Built-in Compiler Settings
Uncheck Use global provider shared between projects
Replace ${COMMAND} with arm-none-eabi-gcc or arm-none-eabi-g++
Alternatively, you can also edit the same setting at the workspace level to affect all the projects in your workspace. Go to Window -> Preferences -> C/C++ -> Build -> Settings -> Discovery tab instead.
Here are some screenshots that may help.
Before:
Project Properties:
After:
As a concrete example, can I add a template for Rust that will allow me to develop, compile, and debug the application from inside Xcode?
My guess is that I would need to build a new Project Template that would configure all the needed XCode parameters like Build Settings, Build Phases, etc.. Setting up the compiler for the new language and supporting the new language characteristics (maybe a language that works on top of LLVM would be easier).
I noticed there is a file type selection box in the file inspector.
Could I add languages to this list?
I'm writing a CPython extension using Jetbrain's CLion IDE and I was hoping to get code-completion working for functions and variables inside of Python.h.
I looked through the preferences and I can't find anything relevant. How do I add code completion and inspection for included libraries?
CLion uses the CMakeLists.txt in your project to control the lookup paths for code completion and other features -- because your library includes are build specific, it makes sense in a way to put this here.
To the specific question of how to get the Python.h library signatures into autocomplete, your CMakeList file should have something like the following:
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -I/usr/local/Cellar/python3/3.4.3/Frameworks/Python.framework/Versions/3.4/include/python3.4m")
Where -I/path/to/file.h is the local path to the directory that contains the header files that you want to include in your build (and by proxy, your autocomplete lookup for the project).
Lets say I have a solution S1 with two projects pdep and pmaster, respectively creating a static and dynamic library. I have the configurations:
release win32 : produces pdep.lib
debug win32 : produces pdepd.lib
release x64 : produces pdepx64.lib
debug x64 : produces pdepx64d.lib
pmaster link configuration is done by Configuration Properties -> Linker -> Input -> Additional Dependencies
No #pragma comment(lib ) in the code. No common properties references.
What I observe :
In s1 with both pdep and pmaster the command line for the linker is fine. ie /LIBPATH:"c:\pdep\lib\x64\Release" "pdepx64.lib"
In a solution S2 freshly created by clicking on the project pmaster, I always have an additional line with an absolute path to a specific version of pdep, regardless of the configuration. ie /LIBPATH:"c:\pdep\lib\x64\Release" "pdepx64.lib" "c:\pdep\lib\pdepd.lib"
How does the linker in S2 derives the additional option "c:\pdep\lib\pdepd.lib"? How do I get rid of it?
Multiple possibilities:
Common Properties -> References
Link Library Dependencies in Linker or Librarian section. This assumes that Project Dependencies have been setup.
#pragma comment(lib...) is playing some role
You can flatten the project file using msbuild with a preprocess flag. Then load that into a plain text or xml editor. Look at the linker command and see what $(properties) hold the options, and then look at where that is being set.
With msbuild you can also use more verbose logging and it will report which conditions are evaluated and such.
I have a Xcode project for library arith.
I could build it with debug configuration, and I need to debug it. How can I do that?
The ideal method would be to set up a test code to build an execution in a project file, and then set a breakpoint in a source code in arith library.
However, it seems that Xcode arith project doesn't allow to add another use_arith project that uses the arith library.
What method people use to debug a dynamic library in Xcode?
ADDED
I googled and found some ways to debug dll. Attaching to a running process can be one way of debugging dynamic library. And, for iPhone/iPad programming dynamic library is not allowed, so static library is used.
Attaching to a Running Process - http://gcc.gnu.org/onlinedocs/gnat_ugn_unw/Attaching-to-a-Running-Process.html
Debugging a library with Xcode - Debugging a library with Xcode
Easy, Modular Code Sharing Across iPhone Apps: Static Libraries and Cross-Project References - http://www.clintharris.net/2009/iphone-app-shared-libraries/
I could find a way to debug dynamic library in Xcode.
Build
Make a library, I'll call this arith library. Debug build to make libarith.dylib.
Make a project to use the library, I'll call this usearith.
For userarith, Project->Add To Project, and add the arith library.
Open Project info, and open the Build tab.
Go to Search Paths/Library Search Paths, drag and drop the arith library. You should remove the library name as you need only specify the path. Specify the header directory with 'Header Search Paths'.
Go to Linking, set Other Linker Flags, add -larith
Running
Now, you should be able to link the execution binary to the library.
For running, you need to copy the dynamic library to the directory where the execution binary is located.
Debugging
You need to set the breakpoints both arith/usearith.
You can run debugger in arith and use the step into to debug the code in a arith project.
I faced the same problem and no one of the previous answer worked for my case so I share my solution (for Xcode):
If you need to debug a c/c++ dylib which is loaded by an external (executable) program:
First be sure that your dylib is build with the same architecture as your external program.
Then Go to --> Product —>Scheme—>Edit scheme
Got to Tab Run(Debug) and check "Debug Executable" , then select into the dropdown button your external program as executable. Then check "Launch Automatically"
Additionally if you program needs extra argument you can add it into the
"Arguments" tab.
Finally you set some breakpoints to your c source file and finally click run.