glUseProgramObjectARB invalid operation error - c

I'm getting an "invalid operation" error when trying to use glUseProgramObjectARB and I have no idea why.
The shader programs are loading correctly, I'm fairly sure. This is shown on glGetInfoLogARB:
Vertex shader was successfully compiled to run on hardware.
Fragment shader was successfully compiled to run on this hardware.
There are no previous openGL errors before this command. So something with this specific command definitely appears to be the issue.
I'm using glew with SDL. I was using GLee before, and getting the same problem.
Reading the documentation I assume it is this error:
GL_INVALID_OPERATION is generated if program could not be made part of current state.
but I'm not sure exactly what could cause such a thing. The command is issued in a working openGL context, as all the previous shader commands work fine. It is not between a "begin" and "end" block.
Really I am stumped as to what it could mean. Perhaps there is some more specific case when the command can't be issued. If anyone knows anything more that would be great.
EDIT:
Solved: oh jesus that was retarded, I was missing a return on one of my function calls elsewhere and so wasn't passing back the program I'd constructed.

Without seeing your code it's hard to know, but since you explicitly mention the results of glCompileShaderARB (times two) but not glLinkProgramARB I will guess that you forgot to glLinkProgramARB (after which, by the way, you can safely glDeleteObjectARB the two shader objects).

Related

Every IDE falls into disassembly mode during debugging

I have installed Linux (Ubuntu 16.04) recently, then QtCreator. Every time when I try to debug my C program in it, it falls into disassembly mode, it means when I try to step into, or even step over, it opens a file "Disassasembly(...)" and navigates in this file. It happens not only for standard functions like malloc (which source code I don't have), but also for my own functions. I thought it's because of the IDE, and installed NetBeans - and I have exactly the same problem in it.
Some example:
[it is shown after stepping over my function, and this function is just the beginning of my program, but the program ends after this screen] - edit: sorry I had to remove this file, because I can post only 2 links..
Another problem is when even for a short moment it navigates on my code (not on disassembly), it executes lines which contains documentation, and gets out to the body of another fuction, which isn't called by me at all(!) It looks like a mess...
So, I think it might be some problem with GDB, but I have no idea how to solve it. Could you help me?
GDB v. 7.11.1
gcc v. 5.4.0
NetBeans v. 8.2
EDIT: It became really weird. Today, when I tried to debug it once again, without any changes in code nor settings, the debugger started to behave almost normally, it means, that it steps through my code correctly now. The only moment, when it falls into dissasembly mode, is the end of my program, when last instruction has executed and it should end. This screens should help:
(1)
(2)
EDIT2: Ok, maybe it is quite normal now. But I still have no idea, what was wrong, and what solved the problem. I hope that it won't come back :)

String Manipulation in C, <optimized out> error

I was solving cs50x pset6 Webserver problem and I would be very grateful if someone could help me.
Can anyone explain what is happenning below in gdb(also in source code itself) please?
Optimized out and Gone String Variable
The problem is that manipulation string variables is needed in this problem set, but somehow I lose them whenever new variable comes up(along).
I tried compiling differently as suggested by some sources e.g. https://cs50.stackexchange.com/questions/9033/variable-optimized-out-eventhough-it-will-be-used-later .
But nothing has changed even I tried other solutions.
So guys I will appreciate if you can help me to fix this issue.
Here is my source code(lines 151-391): http://codepaste.net/2uipag
Edit: This error is affecting not just debugging mode, but the program itself isn't giving intended result. Basically:
Line ="GET /cat.html HTTP/1.1"
absolute_path="/cat.html" (extracted using strncpy())
root="/home/jharvard/pset6/public"
path= root along with absolute_path (strcat())
Because absolute_path is optimized out instead of getting "home/jharvard/pset6/public/cat.html" for path variable, I am getting "home/jharvard/pset6/public"
I apologize for being unclear and thank you for assistance.
It is difficult to say what is happening with any specificity, but most likely, at some point after the last use of your line pointer by the function, the optimized version of the program re-uses its storage for something else. If the variable is still in scope at that point then in principle you should still be able to examine its value, but if your program in fact does not examine its value then it makes no difference in program behavior. Except as viewed via a debugger.
If you intend to run your code in a debugger then it is best to compile it (for that purpose) with optimization disabled (option -O0 for many C compilers, including gcc). After you have worked out the problems, compile your final program with whatever optimization level you deem appropriate.

Break for C compilation

I am new to C. I encountered an error message which involves unexpected "}". However, I checked the number of "}" with an editor and indeed they pair up.
Then I wonder if there is a compiler command, so the compilation can stop whatever I want? It will be convenient to have such tool as debug help.
Thank you.
(Edited in 29-10-2015)
I typically write my code with gedit. Nonetheless, since my work is mostly done on cluster, it will be troublesome to transport the files up and down. I must turn to nano, vi or vim which causes difficulty in debugging.
Stopping compilation partway through is rarely a useful feature. You'll want to see all of the errors that may exist in your code so you can fix more that just one at a time.
That said, an error such as a misplaced brace or parenthesis can cascade down and cause several more errors to appear. So if you see a long list of errors that don't seem to make sense when you look at the code, start at the top and fix that, then recompile to see if it took care of any others.
The answer is no compilers are all or nothing.
However, a good editor is recommended. For example, you can match brackets with the % command in vi, or if you have a color editor, you can visually see what's going on. A better IDE would even allow you to hide/show blocks of code, format it with proper indentation, and flag any compilation issues from static rules without actually compiling your code.

regex.h causes exception in VisualStudio 2010

I wanted to show my students how to use regular expresions. As they are learn programming in C, I thought it would be the best to use regex.h from GnuWin32 (http://gnuwin32.sourceforge.net/packages/regex.htm). As an example I tried to run http://www.peope.net/old/regex.html programm, but it causes an exception on the variable holding the regular expression at runtime . The precise error message is:
Run-Time Check Failure #2 – Stack around the variable 'regex' was corrupted
The courius thing is that the example itself is running properly and the regex functions seems to work properly. The error happens after all the important things are over at the point where main() wants to return.
Has anybody an idea of why this error occurs? Could the 64-Bit System I'm using be part of the problem?
Thanks for any advice!

Something wrong with C wrapper for Matlab

I'm currently facing an apparently silly problem with Matlab but I just can't figure out what is wrong (or better yet, I think it is wrong, but I'm being told it should work).
I have a Matlab script, "myscript.m" which needs to use a C-programmed function, "myfunc.c" which in turn has been compiled (or "lives") inside a library, "mylib.dll". In order for "myscript.m" to access and execute "myfunc.c" there is also a "myfunc.m" Matlab script, which is being called in "myscript.m". However, "myfunc.m" is a completely empty file, except for some comments (in no particular format or pattern either). All of these files were given to me and I'm being told that as it is, Matlab should correctly execute "myfunc.c" because "myfunc.m" is acting as a wrapper.
The problem I'm having is that it is of course not working. When I execute the line in "myscript.m" that reads:
output1 = myfunc(input1, input2);
I get Matlab errors saying that I'm trying to execute a script as a function. In my mind, this is correct, because I'm sending input and requesting outputs to something that is stated to have neither, since "myfunc.m" is empty (except for the comments, which are NOT code).
I think that Matlab has no way (as it is) to know that I want to access the C code inside "mylib.dll". I also DO NOT have a header file "mylib.h" so that I can load the library in Matlab using loadlibrary.
My question is, given the current description, could this execution work at all? Is there any way to make it work, or something that I'm missing? One possibility is that this is an old wrapper format and it currently doesn't work anymore.
If anyone knows anything or has suggestions, they will be greatly appreciated. Thanks!!!
Hugo
it sounds like myfunc.c is a mex file. try compiling it in Matlab using mex command. The dll extension is maybe old version matlab.
Have you tried with loadlibrary? You need a .h file but it's easy recreate on if you know the prototype of the function.

Resources