I'm using Eclipse Mars, with gdb 7.2.
While trying to debug a C++ application in Eclipse gdb DSF, I'm getting a parse exception. But I don't get the parse exception when I run the same program with gdb outside of Eclipse.
The exception states: "Fatal error during XML Parsing: unable to open primary document entity /path/to/file.xml"
But the actual path in xml is a relative path: "../../../../path/to/file.xml".
The C++ application is reading in the XML and trying to open this file.
It's as if the ../..'s are just getting chopped off, and that's why the error states essentially "I don't know about a /path/to/file.xml"
I imagine that something is wrong with my gdb setup in Eclipse, but I'm not sure what. I've tried many different things, none of which seem to work.
I imagine that this has something to do with relative paths not being recognized by gdb, or the working path being different in Eclipse vs gdb.
Does anyone have an idea what is wrong?
You need to make sure the Working Directory matches the location of the executable in the File System.
https://sourceware.org/gdb/onlinedocs/gdb/Working-Directory.html
Actually, this was a simple issue: It turns out that my Working Directory(in Debug Configurations under the Arguments tab) had to be set to the full path of the location of my executable.
I also had to set the path of my executable to the full File System path of the executable.
It works as expected now.
As a C# developer, I have become highly dependent on the automatic formatting in Visual Studio 2008. Specifically, I will use the CTRL + K , D keyboard shortcut to force things back into shape after my sloppy implementation.
I am now trying to learn Objective-C and am missing certain features in Xcode, but probably none are quite as painful as the formatting shortcut. My Google searches have yielded nothing built in, though it seems there are some hacks. Am I missing something or does this feature not exist natively in Xcode?
That's Ctrl + i.
Or for low-tech, cut and then paste. It'll reformat on paste.
Unfortunately, Xcode doesn't have anything nearly as extensive as VS or Jalopy for Eclipse available. There are SOME disparate features, such as Structure > Re-Indent as well as the auto-formatting used when you paste code into your source file. I am totally with you, though; there definitely should be something in there to help with formatting issues.
I'd like to recommend two options worth considering. Both quite new and evolving.
ClangFormat-Xcode (free) - on each cmd+s file is reformatted to specific style and saved, easy to deploy within team
An Xcode plug-in to format your code using Clang's format tools, by
#travisjeffery.
With clang-format you can use Clang to format your code to styles such
as LLVM, Google, Chromium, Mozilla, WebKit, or your own configuration.
Objective-Clean (paid, didn't try it yet) - app raising build errors if predefined style rules are violated - possibly quite hard to use within the team, so I didn't try it out.
With very minimal setup, you can get Xcode to use our App to enforce
your rules. If you are ever caught violating one of your rules, Xcode
will throw a build error and take you right to the offending line.
In xcode, you can use this shortcut to Re-indent your source code
Go to file, which has indent issues, and follow this :
Cmd + A to select all source codes
Ctrl + I to re-indent
Hope this helps.
My personal fav PrettyC wantabe is uncrustify: http://uncrustify.sourceforge.net/. It's got a few billion options however so I also suggest you download UniversalIndentGUI_macx, (also on sourceforge) a GUI someone wrote to help set the options the way you like them.
You can then add this custom user script to uncrustify the selected text:
#! /bin/sh
#
# uncrustify!
echo -n "%%%{PBXSelection}%%%"
/usr/local/bin/uncrustify -q -c /usr/local/share/uncrustify/geo_uncrustify.cfg -l oc+ <&0
echo -n "%%%{PBXSelection}%%%"
You can use Command + A to select all content and next Ctrl + I to format the selected content.
I also feel xcode should have this function.
So I made an extension to do it: Swimat
Simple install by brew cask install swimat
You can give it a try, see https://github.com/Jintin/Swimat for more information.
Cmd A + Ctrl I
Or Cmd A And then Right Click. Goto Structure -> Re-Indent
Consider buying yourself a license for AppCode, an intelligent Objective-C IDE that helps iOS/OS X developers. AppCode is fully compatible with Xcode, but goes beyond Xcode in adding powerful features.
AppCode an Objective-C variant of the Intellij IDEA IDE from JetBrains. They are also authors of popular ReSharper extension to Visual Studio, which main purpose from here seems like a desperate attempt to bring a touch of IDEA experience to a Microsoft product.
AppCode is using its own code analyser which gives close-to-perfect refactoring and code navigation support. There is an ability to re-indent and completely reformat code also (although I still keep missing a couple of formatting settings in hard cases, but mostly it works well).
You might try the trial version, of course.
Swift - https://github.com/nicklockwood/SwiftFormat
It provides Xcode Extension as well as CLI option.
CTRL + i
that's it.
(no COMMAND + i)
You can also have a look at https://github.com/octo-online/Xcode-formatter which is a formatter based on Uncrustify and integrated into Xcode. Works like a charm.
You could try that XCode plugin https://github.com/benoitsan/BBUncrustifyPlugin-Xcode
Just clone github repository, open plugin project in XCode and run it. It will be installed automatically. Restart Xode before using formatter plugin.
Don't forget to install uncrustify util before. Homebrew, for exmaple
brew install uncrustify
P.S. You can turn on "after save formatting" feature at Edit > Format Code > BBUncrustifyPlugin Preferences > Format On Save
Hope this will be useful for u ;-)
I suggest using ClangFormat. In order to install, please follow these steps:
Install Alcatraz package manager for XCode
Supports Xcode 5+ & OS X 10.9+
After installation restart XCode.
Open XCode -> Window Menu -> Package Manager
Search (find) ClangFormat and install it. After installation again restart XCode.
Now at XCode menu you can use Edit -> Clang Format submenu for formatting.
You can choose different types of formatting. Also by enabling Format On Save you can gain auto-format capability.
If your Xcode version 3.x , you should use "User Script" With Uncrustify , here this a Example:
#!/bin/sh
echo -n "%%%{PBXSelection}%%%"
$YOURPATH_TO_UNCRUSTIFY/uncrustify -q -c $YOURPATH_TO_UNCRUSTIFY_CONFIG/CodeFormatConfig.cfg -l OC+
echo -n "%%%{PBXSelection}%%%"
add above to your Xcode "User Script".
if Xcode version 4.x , I think you should read this blog : Code Formatting in Xcode 4,
In this way , used the "Apple Services" , but it's not good enough , cause too slow experience, does anyone has the same thing ?
why apple drop "user script" .... xD
First, Examine XCode Preferences "Indentation" section. You can customize things quite a bit there...
For more fine grained control, refer to the XCode User Defaults document from apple. (May require a developer login to view). For example, I was able to disable the "indent on paste" by entering the following in terminal:
defaults write com.apple.XCODE PBXIndentOnPaste No
to read back your setting:
defaults read com.apple.XCODE PBXIndentOnPaste
This only works for languages with are not whitespace delineated, but my solution is to remove all whitespace except for spaces, then add a newline after characters that usually delineate EOL (e.g. replace ';' with ';\n') then do the ubiquitous ^+i solution.
I use Python.
Example code, just replace the filenames:
python -c "import re; open(outfile,'w').write(re.sub('[\t\n\r]','',open(infile).read()).replace(';',';\n').replace('{','{\n').replace('}','}\n'))"
It 's not perfect (Example: for loops), but I like it.
We can use Xcode Formatter which uses uncrustify to easily format your source code as your team exactly wants to be!.
Installation
The recommended way is to clone GitHub project or download it from https://github.com/octo-online/Xcode-formatter and add the CodeFormatter directory in your Xcode project to get :
Xcode shortcut-based code formatting: a shortcut to format modified sources in the current workspace
automatic code formatting: add a build phase to your project to format current sources when application builds
all sources formatting: format all your code with one command line
your formatting rules shared by project: edit and use a same configuration file with your project dev team
1) How to setup the code formatter for your project
Install uncrustify
The simplest way is to use brew:
$ brew install uncrustify
To install brew:
$ ruby –e “$(curl –fsSkl raw.github.com/mxcl/homebrew/go)”
Check that uncrustify is located in /usr/local/bin
$ which uncrustify
If your uncrustify version is lower than 0.60, you might have to install it manually since modern Objective-C syntax has been added recently.
Add CodeFormatter directory beside your .xcodeproj file
Check that your Xcode application is named "Xcode" (default name)
You can see this name in the Applications/ directory (or your custom Xcode installation directory). Be carefull if you have multiple instances of Xcode on your mac: ensure that project's one is actually named "Xcode"!
(Why this ? This name is used to find currently opened Xcode files. See CodeFormatter/Uncrustify_opened_Xcode_sources.workflow appleScript).
Install the automator service Uncrustify_opened_Xcode_sources.workflow
Copy this file to your ~/Library/Services/ folder (create this folder if needed).Be careful : by double-clicking the .workflow file, you will install it but the file will be removed! Be sure to leave a copy of it for other users.
How to format opened files when building the project
Add a build phase "run script" containing the following line:
sh CodeFormatter/scripts/formatOpendSources.sh
How to format files in command line
To format currently opened files, use formatOpenedSources.sh:
$sh CodeFormatter/scripts/formatOpendSources.sh
To format all files, use formatAllSources.sh:
$sh CodeFormatter/scripts/formatAllSources.sh PATH
PATH must be replaced by your sources path.
E:g; if project name is TestApp then the command will be
$sh CodeFormatter/scripts/formatAllSources.sh TestApp
it will look for all files in the project and will format all the files as configured in uncrustify_objective_c.cfg file.
How to change formatter’s rules
Edit CodeFormatter/uncrustify_objective_c.cfg open with TextEdit
Well I was searching for an easy way. And find out on medium.
First to copy the json text and validate it on jsonlint or something similar. Then to copy from jsonlint, already the json is formatted. And paste the code on Xcode with preserving the format, shortcut shift + option + command + v
We are using an environment variable to specify a path to a library we use. Most of the time it points to the released version but sometimes to a development version.
Anyway, it works ok when I use $(MyLib)/path;%(AdditionalIncludeDirectories) for building the C++ application but I can not open the project resources. However, when I use %(MyLib)/path;%(AdditionalIncludeDirectories) it works.
Now, what is the difference?
I thought the correct way is to use $(EnvVar) but for the resource editor it doesn't seems to work. And if $(EnvVar) is the correct way then why does Visual Studio use %(AdditionalIncludeDirectories) and not $(AdditionalIncludeDirectories)
The error I get is: fatal error RC1015: cannot open include file 'afxres.h'.
You use %(item) to refer to an MSBuild metadata item. Using $(AdditionalIncludeDirectories) would not work well if you also had an environment variable by that name. So %(MyLib)/path ought to resolve to just /path.
You can put echo %(MyLib)/path in a prebuild event to verify this.
Which is probably enough to stop confusing rc.exe, the resource compiler. Which is a stone-cold-old SDK utility, going back all the way to Windows version 1.0. It is pretty temperamental, very picky about command line options and .rc script file text encoding. Do keep in mind that it dates from an era long before Windows started to support a forward slash as a path separator, everybody had to use a backslash back in 1986.
So use "$(MyLib)\path" instead, including the double quotes so you don't confuzzle it when MyLib contains embedded spaces. And do favor using a project property sheet instead so there are some odds that somebody can still figure out how to get the project built correctly 2+ years from now.
I've downloaded Chromium Embedded Framework r306 for Windows and built it. Unfortunately, it shows, that it doesn't support mp3:
<script>
var a = document.createElement("audio");
document.write(a.canPlayType('audio/mpeg'));
</script>
Output is empty and when I try to open an mp3 file, it can't be played (ogg is playable).
The same time Google Chrome writes "maybe" (and it actually plays).
How can I add support for MP3 in CEF?
Marshall Greenblatt (the maintainer of the Chromium Embedded Framework) addresses the lack of support for MP3 (and AAC) in Chromium and CEF in this bug report (see comment #7, copied below):
Codecs like MP3 and AAC are included in Google Chrome releases but not Chromium builds. This is because these formats are not open and require licensing. Distributing these codecs with your application without a licensing agreement may violate the law in certain countries. You should discuss with a lawyer if appropriate.
NOTE: PLEASE CONSIDER LEGAL ISSUES BEFORE PROCEEDING
There is a way to enable MP3 support in CEF, but you'll have to modify the cef.gypi in the source distribution, regenerate the visual studio projects and rebuild.
Step by step instructions:
a
a
There is a way to enable MP3 support in CEF, but you'll have to modify the cef.gypi in the source distribution, regenerate the visual studio projects and rebuild.
Detailed build instructions:
https://bitbucket.org/chromiumembedded/cef/wiki/BranchesAndBuilding
Enabling proprietary codecs support:
http://code.google.com/p/chromiumembedded/issues/detail?id=371
Add 'proprietary_codecs': 1 to your cef.gypi configuration so that USE_PROPRIETARY_CODECS will be defined as required by net/base/mime_util.cc.
You'll also need proper builds of the avcodec, avformat and avutil DLLs. Luckily, you can just get these from the installation directory of Google Chrome itself ($User/AppData/Local/Google/Chrome/$Version).
the options to enable proprietary codecs (i.e. H.264 and MP3) have been moved since the last answer.
you can read my answer with all the details on how to compile CEF with enabled proprietary codecs
the magic now happens here:
set GN_DEFINES=is_official_build=true proprietary_codecs=true ffmpeg_branding=Chrome
there is 2 batch files that you should update/create (as found here):
c:\code\chromium_git\update.bat:
set CEF_USE_GN=1
set GN_DEFINES=is_official_build=true proprietary_codecs=true ffmpeg_branding=Chrome
set GN_ARGUMENTS=--ide=vs2015 --sln=cef --filters=//cef/*
python ..\automate\automate-git.py --download-dir=C:\code\chromium_git --depot-tools-dir=C:\code\depot_tools --no-distrib --no-build
c:\code\chromium_git\chromium\src\cef\create.bat:
set CEF_USE_GN=1
set GN_DEFINES=is_win_fastlink=true proprietary_codecs=true ffmpeg_branding=Chrome
set GN_ARGUMENTS=--ide=vs2015 --sln=cef --filters=//cef/*
call cef_create_projects.bat
There is 2 wiki articles that explain how to build CEF/Chromium:
https://bitbucket.org/chromiumembedded/cef/wiki/MasterBuildQuickStart.md
and BranchesAndBuilding in the same wiki
MP3 codec only be supported When build to Google Chrome, check chromium's Codec Support.
On client side, the compatible way may be Flash, check google translate's code.
I followed the steps in null1941's answer and they worked great save a few caveats having to do with modifying the build.ps1 script
step 16 e. search for any instances of 3.y.z and replace them with the current version you are building (from the folder name containing the builds ex. 3.2272.32.gbda8dc7).
in function DownloadNuget it is trying to see if you have nuget in a specific place and if it isn't there it tries to go get it. Problem is DownloadFile would fail if the save directory didn't already exist. so you can manualy create or add this to the function:
$Nuget_dir = Join-Path $env:LOCALAPPDATA .\nuget
if(-not (Test-Path $Nuget_dir))
{
mkdir $Nuget_dir
}
change line: "Copy-Item $Cef64\include $CefInclude -Recurse | Out-Null" to use $Cef32 if you don't have 64bit cef folders
I'm building my application and when I try to run it on the emulator, I get this error.
Creation Time Description Resource Path Location Type
1254339868582 BLDMAKE ERROR: Directory "\S60\devices\Nokia_N97_SDK_v1.0\epoc32\" does not exist ZeFirst Unknown C/C++ Problem
The folder does exist and does have the necessary rights.
The console has the following set of warning messages
warning: "C:\S60\devices\Nokia_N97_SDK_v1.0\epoc32\tools\GCCEV6.bsf" Invalid BSF specification - customization restricted to ARMV5, ABIv2 and valid BSF platforms
warning: "C:\S60\devices\Nokia_N97_SDK_v1.0\epoc32\tools\GCCEV6T2.bsf" Invalid BSF specification - customization restricted to ARMV5, ABIv2 and valid BSF platforms
warning: "C:\S60\devices\Nokia_N97_SDK_v1.0\epoc32\tools\GCCEV7A.bsf" Invalid BSF specification - customization restricted to ARMV5, ABIv2 and valid BSF platforms
What other development tools do you have installed on your computer?
Is there a chance your path environment variable is in the wrong order and you're not using the correct version of the compiler, for example?
Feel free to post your path, it can only provide more information.
I'm not sure if this will work, but try this:
Subst a drive to C:\S60\devices\Nokia_N97_SDK_v1.0\
Start, Run...
subst x: C:\S60\devices\Nokia_N97_SDK_v1.0\
Then in carbide, set your SDK to point to this subst location.
Window, Preferences, Carbide C++, SDK ..
Change the paths to use "x:\" rather than C:\...
Delete any imported projects in Carbide
Select project, right-click, delete.
(Do NOT click the tick box that is displayed).
Re-import your project
File, Import, x:\.....\bld.inf
I have faced a similar problem once.
If you have been able to build and launch the eumlator on earlier occasions, then the only solution that worked for me was to re-install the SDK.
Techeretic,
make sure that your workspace is located in the same driver partition (C:) of your Symbian SDK installation. If don't try changing it.
Sometimes I solved that problem by changing .pkg file's content to use a relative path. For example:
;Files to install
;You should change the source paths to match that of your environment
;<source> <destination>
"$(EPOCROOT)Epoc32\release\$(PLATFORM)\$(TARGET)\MyApp.exe" -"!:\sys\bin\MyApp.exe"
"$(EPOCROOT)Epoc32\data\z\resource\apps\MyApp.r01" -"!:\resource\apps\MyApp.r01"
"$(EPOCROOT)Epoc32\data\z\private\10003a3f\apps\MyApp_reg.r01" -"!:\private\10003a3f\import\apps\MyApp_reg.r01"
"$(EPOCROOT)epoc32\data\z\resource\apps\MyApp_aif.mif" -"!:\resource\apps\MyApp_aif.mif"
"$(EPOCROOT)epoc32\data\z\resource\apps\MyApp.mbm" -"!:\resource\apps\MyApp.mbm"
Hope it helps.