|
Don't know if this is in the right thread but I'm trying to compile something and I don't understand what this line does.quote:/bin/bash ../libtool --tag=CXX --mode=link g++ -ftemplate-depth-50 -I../include -I../include/libtorrent -Os -pthread -DBOOST_MULTI_INDEX_DISABLE_SERIALIZATION -g -O2 -L./ -lboost_system-gcc43-1_35 -lboost_filesystem-gcc43-1_35 -lboost_thread-gcc43-mt-1_35 -DBOOST_MULTI_INDEX_DISABLE_SERIALIZATION -L/usr/lib -L/usr/lib -lssl -lcrypto -L/usr/lib -o simple_client simple_client.o ../src/libtorrent-rasterbar.la Any ideas?
|
# ¿ Mar 13, 2009 23:17 |
|
|
# ¿ Apr 29, 2024 18:12 |
|
What would be the easiest way to print out a float that's constantly updating onto the terminal? I just started writing in C++ and this is pretty much all I know how to do: getProgress just returns a float value. code:
|
# ¿ Apr 11, 2009 04:35 |
|
Thanks for the prompt reply, that's exactly what I want to do. I was afraid that I'd have to use another library but it's better than flooding my screen with 0.000 0.000 0.000 0.000 0.0001 eh? Thanks again.
|
# ¿ Apr 11, 2009 04:45 |
|
That seems to have worked too. Thanks.
|
# ¿ Apr 11, 2009 06:47 |
|
ctz posted:I believe the behaviour of a carriage return written to a terminal is standard according to POSIX. How do I properly format floats or set them to a smaller precision? Right now I'm just trying std::count.precision(3);
|
# ¿ Apr 11, 2009 21:43 |
|
I'm trying to compile a shared library that also happens to need a static library. How abouts would I do this? This is what I ran to compile my SO. code:
I am so confused . Please help.
|
# ¿ Apr 17, 2009 23:15 |
|
Can someone tell me how to check if the input from std::cin is an integer or not? I ended up using atoi but that doesn't seem right. Thanks
|
# ¿ Jan 18, 2010 21:53 |
|
Anybody here know why I'm getting an assertion failure? I was trying to make a linked list but when I removed something from the top of the list I get an error. That is if I have 3 items in the list, it'll crash after removing two. If I make it four items it works fine. It compiles with no errors but it crashes when I run it. dequeue() seems to be the problem. Here's what I have: Customer is just an ADT with two fields in it. code:
code:
code:
|
# ¿ Jan 23, 2010 08:20 |
|
Brecht posted:I took your code and made it into a compilable program -- I had to define the get_length() method myself, typedef'd int as Customer, and removed Node's constructor and destructor as it didn't seem to need to do anything. That's at http://pastebin.org/80828 -- after making those changes I don't have any problems running the program, adding 3 customers, and removing them. So my guess is either your get_length() is different than mine and it's crashing there, or there's some other ancillary code causing you problems that you haven't listed. Thanks, I've read over your comments and gone through with the suggestions. I still don't know what was wrong with my program, I copied and pasted the methods from your pastebin and it still didn't work (assertion). I ended up rewriting everything and it worked in the end. What the hell. RE: Memory leak, Something like this in the ~LinkList destructor should work, right? while(front != NULL) dequeue(); Acer Pilot fucked around with this message at 23:25 on Jan 23, 2010 |
# ¿ Jan 23, 2010 23:22 |
|
He might find this useful: http://www.cplusplus.com/doc/tutorial/dynamic/ I think that site is listed in the OP too, helped me quite a bit when I started learning C++.
|
# ¿ Mar 9, 2010 05:13 |
|
If they're in a class you'd have two files: myFunctions.h (your header file) myFunctions.cpp (your definitions) You would include myFunctions.h in main.cpp.
|
# ¿ Mar 10, 2010 23:38 |
|
I'm trying to implement a binary search tree and can't, for the love of all things good, figure out what's wrong with my remove function. Please help. code:
I also tried this: code:
|
# ¿ Apr 4, 2010 10:41 |
|
Paniolo posted:Right off the bat I notice you're passing the Customer object by value instead of pointer or reference, which is almost definitely wrong for what you're trying to do. But whether that's the cause of the problem you're having or just another problem waiting to happen is impossible to know because you haven't really specified what your problem is. "It's not working" is not very helpful. Sorry, forgot about get_node() . The problem with my first function is that it seems to delete two nodes (it prints out 2 twice) before it just gives me a runtime error without a prompt to run my VS2008 debugger. Still pretty new to using VS so not sure how to force it to open the debugger... Related question, should parameters for functions that return pointers always be pointers as well? code:
|
# ¿ Apr 4, 2010 11:01 |
|
Okay, I solved the remove problem! I forgot to account for children on some occasions... When should my Customer objects be Customer* and when should they be Customer* &variable?
|
# ¿ Apr 4, 2010 13:58 |
|
Shouldn't it be something like this?code:
Acer Pilot fucked around with this message at 11:24 on Apr 17, 2010 |
# ¿ Apr 17, 2010 11:09 |
|
pseudorandom name posted:pipe(7) I think I'm in the same class as that guy lol. So far I've been able to get it to do this: code:
edit: My function for the forks looks like this: code:
Acer Pilot fucked around with this message at 15:53 on Oct 19, 2010 |
# ¿ Oct 19, 2010 15:49 |
|
roomforthetuna posted:Where do you expect it to update that value? It copies it into "seats_open" and then only updates seats_open. I changed it back to how it was originally now but it still only seems to deduct it from seats_available once... Any ideas on what I did wrong?
|
# ¿ Oct 19, 2010 19:36 |
|
roomforthetuna posted:Though even if it was working as you'd expect, you'd still need some sort of locking anyway, or you risk all 6 processes first reducing the number, then the same reduced number (30) being piped 6 times. This is exactly what's happening now, all 6 processes are reducing the number 6 times. Yikes! Thanks, I'll look through the memory locations and that link. I already did it via POSIX threads but our prof also wanted us to try it out with pipes or sockets. The pthreads seemed pretty easy but I'd never worked with pipes before .
|
# ¿ Oct 19, 2010 20:44 |
|
Anyone have any experience getting QT running with Visual Studio 2010? I can only compile release but not debug. Was thinking about compiling QT from source but I don't think I have the hours it could take to compile. Solutions or alternatives?
|
# ¿ Jun 25, 2011 23:45 |
|
Having some trouble with converting something to float which also happens to be a pointer. Note: projectTestFace is a float* and I'm using OpenCV2.2 for the Matrices. The original: code:
code:
|
# ¿ Aug 6, 2011 09:04 |
|
I'm thinking about using Boost regex to iterate through a queue. I don't know how long the queue will be, could be thousands of entries, and there could be a dynamic number of regexes I'll use. Are there any tradeoffs or better solutions for this? Specifically, the queue will be a long list of URLs and I want to search for specific types of URL. I'm also open to suggestions on what the best type of list/array is best to use for such a list. Should I roll my own?
|
# ¿ Apr 21, 2012 22:38 |
|
Paniolo posted:You should almost never roll your own basic data structure. Certainly never before you've implemented it with a STL vector or list, profiled it, and identified specific characteristics which are causing performance issues. Thanks for the advice, going to try out using a trie instead of using regex, it looks really versatile. I'll use a list as well to store the actual URLs since I think I'll just be going FIFO.
|
# ¿ Apr 22, 2012 00:00 |
|
Paniolo suggested, a few posts up, that I should use a trie. Anyone have any suggestions for a good C++ implementation or library for trie? Preferably one that compiles in GNU.
|
# ¿ Apr 23, 2012 01:32 |
|
Brecht posted:gcc ships with a GNU implementation of a trie. Thanks, I saw that one and am trying out. Another question, what's the MySQL C++ connector of choice around here? I was looking at libmysqlcppconn but the documentation is a little iffy.
|
# ¿ Apr 24, 2012 04:39 |
|
Dicky B posted:Effective C++. This is a good book.
|
# ¿ Apr 30, 2012 02:16 |
|
I have a Boost multithreading question.code:
Right now, I'm thinking there will be 4 producers and one consumer running. Will any of my threads starve if I use Boost mutexes like this? Something doesn't seem right with producer(). Do I need to use a shared_mutex and upgrade locks? Also should I use unique_lock instead or stick with lock_guard? Acer Pilot fucked around with this message at 02:27 on May 4, 2012 |
# ¿ May 4, 2012 02:03 |
|
nielsm posted:If that's what you are actually doing (pushing items into a queue in a producer and consuming them in a bunch of worker threads) then I would suggest looking into using a lock-free queue implementation instead. Your code will be cleaner and likely also faster. Ah, sorry, I was editing my post when I saw yours come up. The producer pops an object from a shared vector, does something to it, then pushes it to a queue. I think that will probably mean it needs a lock. I'm worried that not all 4 of the producers will have access to the shared vector though. e: Can I still do this with a lock-free queue? Acer Pilot fucked around with this message at 02:33 on May 4, 2012 |
# ¿ May 4, 2012 02:29 |
|
Thanks for replying again nielsm. A vector named data is shared between the 4 producers. Each producer pops an object from the data vector, processes it, and then adds the processed object to another shared vector named queue. When the consumer sees that there are 10 items in the queue vector, it processes the contents and empties the queue vector. Now that I write this, I see that I'll probably need another mutex for the data vector. Thanks to your explanation I just realized that I only need to lock a producer when it pops from the data vector. Can starvation still occur though?
|
# ¿ May 4, 2012 02:49 |
|
Thanks a lot nielsm and roomforthetuna! Time to rewrite this junk.
|
# ¿ May 4, 2012 03:16 |
|
What's an easy way to generate an md5 or sha-1 hash of a string? OpenSSL?
|
# ¿ May 20, 2012 00:37 |
|
Isilkor posted:If you already use OpenSSL in your application, then you should probably just use that. If you don't, get some smaller implementation that doesn't pull in hundreds of kilobytes of code, plus a bad license. If you just want SHA-1, boost.uuid has an implementation that's licensed very permissively; look at <boost/uuid/sha1.hpp> but take notice that it isn't part of the public interface (copy it to your own file and namespace if you want to use it). Thanks for the reply. I'm not using it for any security purposes, just trying to figure out an "easy" way to generate a fixed length hash to use for look ups in a database. Do you guys happen to have any alternative ideas to accomplish this? e: Not using OpenSSL in the program but open to it. Using Boost already though. Acer Pilot fucked around with this message at 03:07 on May 20, 2012 |
# ¿ May 20, 2012 03:02 |
|
I'm trying to generate a fixed length hash (that won't likely have collisions) for a value like this: product[max integer of length 10]model[max integer of length 10]price[a float or double of unknown length] I was under the impression that using MD5, SHA1, or SHA256 would be an easy way to generate this but I'd love a more efficient/correct way. Please take note that I might need to be able to generate the hash again in a PHP script.
|
# ¿ May 20, 2012 03:45 |
|
Suspicious Dish posted:You do know what SQL is, right? Yes, I'm doing it to group multiple indexes into a hash rather than doing a large set of subqueries.. We're using a WHERE IN and need a way to look up multiple indexes for a large set of values in a single query.
|
# ¿ May 20, 2012 03:50 |
|
Suspicious Dish posted:And you thought you needed a hash? A cryptographic hash, even? This is an example of the XY problem in action, here. The database will hash values for you. You don't need to. Create a single easily generated value, and use that. Ahh, ok. Thanks everyone.
|
# ¿ May 20, 2012 04:53 |
|
I'm trying to write a daemon in C++ and I think I want it to have child processes. The child processes will all be from the same class but have different data. I plan on having them communicate to each other with pipes or through Boost's IPC so they know when they're supposed to terminate. The question is, where exactly do I spawn the child processes and how? Do I do it in the main loop in the parent process? Here's the code I'm starting off with: code:
|
# ¿ Jul 13, 2012 02:51 |
|
Gazpacho posted:fork() is precisely what spawns the child process. By the time fork() returns, it's all set up. The parent process will return from fork with a positive number and the child will return with 0. From there on you have two processes executing the same code. The return value from fork allows them to take different paths through that code. Thanks for your answer, I thought the code where we check if the pid > 0 was so we could let the system take control of the process and run it as a service in the background. Did I assume incorrectly?? And I guess the better question is, how do I let the daemon create additional processes?
|
# ¿ Jul 13, 2012 06:35 |
|
Crankit posted:How does CodeBlocks compare to NetBeans / Eclipse and vice-versa? Well I like CodeBlocks over Eclipse. NetBeans can make proper Makefiles though if you're lazy, CodeBlocks needs a plugin to do so.
|
# ¿ Aug 6, 2012 22:48 |
|
What's a good library for thread-safe logging to a text file?
|
# ¿ Aug 16, 2012 04:18 |
|
Good ideas, thanks. Now I need to figure out a good way to buffer the messages with little to no blocking.
|
# ¿ Aug 16, 2012 08:01 |
|
|
# ¿ Apr 29, 2024 18:12 |
|
So what's a good way to check if one or more threads have completed their task?
|
# ¿ Aug 23, 2012 02:16 |