I am trying to port a project including both SDL and WxWidgets to MacOS X with XCode 3.1.2. The project is fairly big, but I finally got it to compile successfully. However, it exits immediately after starting it with the message "MyApplication has exited with status 99".
For debugging purposes, I changed my main function to look like this:
int main(int argc, char *argv[])
{
cout <<"hello world";
cout <<"and goodbye";
throw "test";
}
I also added breakpoints to all three main function lines. However, the debugger does still not break and the application still exits right after startup.
The debug console output looks as follows:
(gdb) run [Switching to process 94140
local thread 0x3607] Running…
Debugger stopped. Can't find test.xml
!
Debugger stopped. Program exited with
status value:99.(gdb)
I do not know what file "can't find test.xml" refers to, why XCode is looking for it in the first place or if it is related to my problem at all.
This is my first XCode project, so I am clueless on how to proceed. Any hints would be greatly appreciated.
SDL uses some hack around your main function.
It's likely that your main code is never reached.
Try breaking on "start" and stepping from there - AFAIK "start" is the entry point to any macho executable.
What you're seeing looks like your binary exits with error code "99".
You may want to look for error code 99 in SDL or WX.
Later edit: from SDL site: The header file "SDL_main.h" remaps your main() function to the SDL_main() function with a function macro.
You probably don't have the right project settings. Which project template did you choose?
In the end I found that there was a different main() function in a unit test file from a third party library I had included by mistake.
And I expect that test.xml is a data file for that unit test, and it may have expected it in a default directory. Project > Edit Active Executable and make sure that the working directory on launch is where the code expects it to be (root, project directory, or executable directory).
I have to say, though, that I don't recommend learning a new tool by porting source code you're unfamiliar with to it. You are going to have a hard time telling what problems are due to learning Xcode from what problems are due to the odd expectations of SDL/WxWidgets.
Related
I'm building AOSP from source and have created a small C++ program that prints some messages to logcat when started. Now I wanted to debug the program according to https://source.android.com/devices/tech/debug/gdb
In the reference you're encouraged to use lldb in favor of gdb and there is also a short section on using vs code as debugger.
However, I cannot find the mentioned script lldbclient anywhere in my source nor in Android Code Search, only gdbclient.py seems to be present.
Q1: Where can I find lldbclient script?
When running the gdbclient.py script the option --setup-forwarding vscode seems to be ignored and gdb is always started.
Q2: If there isn't a lldbclient script, what options do I have to pass to gdbclient.py to enable debugging with lldb and vs code?
What did I do so far?
gdbclient.py -r /data/mysample_bin --setup-forwarding vscode
Starts my native program with attached gdb and allows me to step through my program.
Though I do not know how to code python, I was able to track down a call sequence in the script to method generate_setup_script, which is called with parameter debugger=gdb. Therefore no lldb configuration for vs code is created. Passing --no-gdb or --lldb to the script doesn't change this behavior.
Q1: You can find lldbclient.py script in the repository https://android.googlesource.com/platform/development, branch android-s-beta-2 (or another android-s branch).
Q2: Android also provides some tutorial debugging with Vscode: https://source.android.com/devices/tech/debug/gdb#vscode.
I setup a breakpoint in my Go code with runtime.Breakpoint(), save the file (my editor, Atom with go-plus installed, runs go install . on save). Then I run Delve in terminal with dlv debug, and type continue after it starts.
When the breakpoint kicks in, I want to test a couple of things (basically to print reader's data via a bytes.Buffer). But, I get the following error
buf := new(bytes.Buffer): "1:5: expected 'EOF', found ':='"
and in general cannot do much more than print values.
Is it really not possible to do this sort of thing? I am used to Python's pdb where setting variables or calling functions is not a problem and I would expect Delve is capable of the same.
So, what am I doing wrong?
Not possible yet. Right now (2018-NOV) work is in progress on Delve, but unfinished.
Go runtime was changed recently to allow this kind of call. Delve have a Github issue tracking the progress of such feature, but is still experimental and incomplete.
I'm trying to run the demo code for suave (a webserver) in Xamarin Studio 5.9.8 on OS X El Capitan.
module ServerTest =
open Suave // always open suave
open Suave.Http.Successful // for OK-result
open Suave.Web // for config
startWebServer defaultConfig (OK "Hello World!")
It works as expected when I actually build the code. But when I try running it interactively, with ctrl + return, I get the error The namespace or module 'Suave' is not defined. I've looked around, and it looks like it's possible to use libraries interactively with Visual Studio. Is there a way to get this to work on OS X?
When you build your code, the information about referenced DLLs is contained not in the code itself, but elsewhere (the project file).
But when you execute the code in FSI, all FSI sees is the code. It doesn't have a project file from which to get references.
But since FSI still needs to load referenced DLLs occasionally (otherwise, it wouldn't be very useful), it offers a way to encode them in the code. This way is described in the page you linked - specifically, the #r directive.
Unfortunately, these directives are not supported when you build the code with the compiler. The compiler will generate an error when it sees them.
So it would seem that you have a choice: either execute the code with FSI or build it with compiler. Can't use the same code for both.
Fortunately, there are a couple of tricks to work around this.
First, you could leverage a special conditional compilation variable called INTERACTIVE and put the #r directive inside an #if such that only FSI will see it, but compiler won't:
#if INTERACTIVE
#r "./path/to/my.dll"
#endif
Second, you could create a separate script file that will load references and then load your actual code file:
#r "./path/to/my.dll"
#load "./my_code.fs"
And then execute this script file with FSI.
In both these cases, the paths are relative to the script file.
This means that the "not found" error you're getting is probably due to incorrect path to the Suave DLL. I seriously doubt that the DLL is located in the same directory with the code file. And also that it has no extension.
Earlier I was using gtest for my project. For the time being I am using gmock and when I have provided the path for gmock.lib, gmock_mock.lib and ..\..\include too. Then the control is not at all going into the code.
Suppose previously it was like e.g.
main()
{
printf("Hello world"); //Kept the breakpoint here, control comes here
}
Now after adding .lib and include paths it is not at all executing just strats debug and ends without going anywhere...
Please help me.
Google test lets you write unit tests using the TEST macro. It is not intended for use with normal programs that already have a main(). If you want to use google test you should create another project.
I thought I might try out Visual Studio 2012 so I created a simple console 'hello world' application that makes a beep noise whenever it is run, but when I went to compile it it took 25 seconds. Now I know for a fact that the simplest of 'hello world' programs, on a modern system with 3.2gHz of i7 shouldn't take that long to compile. Is there a setting or feature that I could disable that was added in 2012 that made compiling basic console apps incredibly slow?
#include <iostream>
using namespace std;
string returnvalue;
int main()
{
cout << "Hello World\a";
return 0;
}
This sounds like there's something else on your system that is interfering with the compilation, as a single file like this should only take about a second to build. I would suggest running Process Monitor while doing a build and then look at the summaries in Tools -> Process Activity Summary/File Summary. It's likely that it'll point to the problem on your system which may be something like:
Virus/spyware scanner or some other process that hooks into all the file accesses. Desktop search tools do this too.
Permissions problem where a file or directory can't be read or written
Accessing files on a network drive which may be unavailable
Other network communication with servers that may not be available
Use pre-compiled headers. It will be slow the first time, but after that it will breeze right through it. Include <iostream> in your pre-compiled header .h file.
The easiest way would be to start over and use the default configuration, which uses pre-compiled headers. Or...
See here for how to add precompiled headers to an existing project: How to fix .pch file missing on build?