Search Results

Search found 19441 results on 778 pages for 'static libraries'.

Page 10/778 | < Previous Page | 6 7 8 9 10 11 12 13 14 15 16 17  | Next Page >

  • How to define a static operator<<?

    - by Pietro M
    Is it possible to define a static insertion operator which operates on the static members of a class only? Something like: class MyClass { public: static std::string msg; static MyClass& operator<< (const std::string& token) { msg.append(token); return *this; // error, static } }; alternatively: static MyClass& operator<< (MyClass&, const std::string &token) { MyClass::msg.append(token); return ?; } This is how I would like to use it: MyClass << "message1" << "message2"; Thank you!

    Read the article

  • Why are static imports of static methods with same names legal?

    - by user1055638
    Lets say we have these packages and classes: package p1; public class A1 { public static void a() {} } package p2; public class A1 { public static void a() {} } package p3; import static p1.A1.a; import static p2.A1.a; public class A1 { public static void test() { } } I am wondering, why the static import of methods is legal (won't result in compile time error) in package p3? We won't be able to use them further in the test() method as such usage will result in the compile time error. Why it is not the same as with a normal import of classes. Lets say we would like to import classes A1 from packages p1 and p2 into p3: package p3; import p1.A1; import p2.A1; such import is illegal and will result in the compile time error.

    Read the article

  • Dynamic loaded libraries and shared global symbols

    - by phlipsy
    Since I observed some strange behavior of global variables in my dynamically loaded libraries, I wrote the following test. At first we need a statically linked library: The header test.hpp #ifndef __BASE_HPP #define __BASE_HPP #include <iostream> class test { private: int value; public: test(int value) : value(value) { std::cout << "test::test(int) : value = " << value << std::endl; } ~test() { std::cout << "test::~test() : value = " << value << std::endl; } int get_value() const { return value; } void set_value(int new_value) { value = new_value; } }; extern test global_test; #endif // __BASE_HPP and the source test.cpp #include "base.hpp" test global_test = test(1); Then I wrote a dynamically loaded library: library.cpp #include "base.hpp" extern "C" { test* get_global_test() { return &global_test; } } and a client program loading this library: client.cpp #include <iostream> #include <dlfcn.h> #include "base.hpp" typedef test* get_global_test_t(); int main() { global_test.set_value(2); // global_test from libbase.a std::cout << "client: " << global_test.get_value() << std::endl; void* handle = dlopen("./liblibrary.so", RTLD_LAZY); if (handle == NULL) { std::cout << dlerror() << std::endl; return 1; } get_global_test_t* get_global_test = NULL; void* func = dlsym(handle, "get_global_test"); if (func == NULL) { std::cout << dlerror() << std::endl; return 1; } else get_global_test = reinterpret_cast<get_global_test_t*>(func); test* t = get_global_test(); // global_test from liblibrary.so std::cout << "liblibrary.so: " << t->get_value() << std::endl; std::cout << "client: " << global_test.get_value() << std::endl; dlclose(handle); return 0; } Now I compile the statically loaded library with g++ -Wall -g -c base.cpp ar rcs libbase.a base.o the dynamically loaded library g++ -Wall -g -fPIC -shared library.cpp libbase.a -o liblibrary.so and the client g++ -Wall -g -ldl client.cpp libbase.a -o client Now I observe: The client and the dynamically loaded library possess a different version of the variable global_test. But in my project I'm using cmake. The build script looks like this: CMAKE_MINIMUM_REQUIRED(VERSION 2.6) PROJECT(globaltest) ADD_LIBRARY(base STATIC base.cpp) ADD_LIBRARY(library MODULE library.cpp) TARGET_LINK_LIBRARIES(library base) ADD_EXECUTABLE(client client.cpp) TARGET_LINK_LIBRARIES(client base dl) analyzing the created makefiles I found that cmake builds the client with g++ -Wall -g -ldl -rdynamic client.cpp libbase.a -o client This ends up in a slightly different but fatal behavior: The global_test of the client and the dynamically loaded library are the same but will be destroyed two times at the end of the program. Am I using cmake in a wrong way? Is it possible that the client and the dynamically loaded library use the same global_test but without this double destruction problem?

    Read the article

  • GHC 6.12 and MacPorts

    - by absz
    I recently installed GHC 6.12 and the Haskell Platform 2010.1.0.1 on my Intel MacBook running OS X 10.5.8, and initially, everything worked fine. However, I discovered that if I use cabal install to install a package which depends on a MacPorts library (e.g., cabal install --extra-lib-dirs=/opt/local/lib --extra-include-dirs=/opt/local/include gd), things work fine in GHCi, but if I try to compile, I get the error Linking test ... Undefined symbols: "_iconv_close", referenced from: _hs_iconv_close in libHSbase-4.2.0.0.a(iconv.o) "_iconv", referenced from: _hs_iconv in libHSbase-4.2.0.0.a(iconv.o) "_iconv_open", referenced from: _hs_iconv_open in libHSbase-4.2.0.0.a(iconv.o) ld: symbol(s) not found collect2: ld returned 1 exit status After some Googling, I found a long Haskell-cafe thread discussing this problem. The upshot seems to be that MacPorts installs an updated version of libiconv, and the binary interface is slightly different from the version included with the system. Consequently, if you try to link with any MacPorts library, the MacPorts libiconv gets linked in too; and since the base library was built to link against a different version of libiconv, things break. I've tried setting LD_LIBRARY_PATH and DYLD_LIBRARY_PATH and adding more flags to try to get it to look at /usr/lib again (e.g. cabal install --extra-lib-dirs=/opt/local/lib --extra-include-dirs=/opt/local/include --extra-lib-dirs=/usr/lib --extra-include-dirs=/usr/include gd), but neither worked. Uninstalling the MacPorts libiconv isn't really an option, since I have a bunch of ports installed which depend on it---including some ports I want Haskell to link to, like gd2. From what I've seen online, the upshot really seems to be "you're boned": you cannot link against any MacPorts library while compiling with GHC, and there doesn't seem to be a solution. However, that thread was from the end of 2009, so I figure there's a chance that someone has a solution, workaround, ridiculous hack… anything, really. So: does anybody know how to get GHC 6.12 to link against the system libiconv at the same time as it links to libraries from MacPorts? Or, failing that, a way to make linking not break in some other clever way?

    Read the article

  • iPhone static library Clang/LLVM error: non_lazy_symbol_pointers

    - by Bekenn
    After several hours of experimentation, I've managed to reduce the problem to the following example (C++): extern "C" void foo(); struct test { ~test() { } }; void doTest() { test t; // 1 foo(); // 2 } This is being compiled for iOS devices in XCode 4.2, using the provided Clang compiler (Apple LLVM compiler 3.0) and the iOS 5.0 SDK. The project is configured as a Cocoa Touch Static Library, and "Enable Linking With Shared Libraries" is set to No because I'm building an AIR native extension. The function foo is defined in another external library. (In my actual project, this would be any of the C API functions defined by Adobe for use in AIR native extensions.) When attempting to compile this code, I get back the error: FATAL:incompatible feature used: section type non_lazy_symbol_pointers (must specify "-dynamic" to be used) clang: error: assembler command failed with exit code 1 (use -v to see invocation) The error goes away if I comment out either of the lines marked 1 or 2 above, or if I change the build setting "Enable Linking With Shared Libraries" to Yes. (However, if I change the build setting, then I get multiple ld warning: unexpected srelocation type 9 warnings when linking the library into the final project, and the application crashes when running on the device.) The build error also goes away if I remove the destructor from test. So: Is this a bug in Clang? Am I missing some all-important and undocumented build setting? The interaction between an externally-provided function and a struct with a destructor is very peculiar, to say the least.

    Read the article

  • Mac OS X and static boost libs -> std::string fail

    - by Ionic
    Hi all, I'm experiencing some very weird problems with static boost libraries under Mac OS X 10.6.6. The error message is main(78485) malloc: *** error for object 0x1000e0b20: pointer being freed was not allocated *** set a breakpoint in malloc_error_break to debug [1] 78485 abort (core dumped) and a tiny bit of example code which will trigger this problem: #define BOOST_FILESYSTEM_VERSION 3 #include <boost/filesystem.hpp> #include <iostream> int main (int argc, char **argv) { std::cout << boost::filesystem::current_path ().string () << '\n'; } This problem always occurs when linking the static boost libraries into the binary. Linking dynamically will work fine, though. I've seen various reports for quite a similar OS X bug with GCC 4.2 and the _GLIBCXX_DEBUG macro set, but this one seems even more generic, as I'm neither using XCode, nor setting the macro (even undefining it does not help. I tried it just to make sure it's really not related to this problem.) Does anybody have any pointers to why this is happening or even maybe a solution (rather than using the dynamic library workaround)? Best regards, Mihai

    Read the article

  • How do I create and conveniently search through Libraries in Windows 8?

    - by mtone
    In Windows 7, I took the habit of putting most of my frequently accessed disk areas as Libraries - there were about a dozen. Typing a word in the Start menu would then give me a summary of matches by Library. For example, searching for "WPF" would tell me that I've got some results in the Books library, in the Coding library and a few other PDFs in the Downloads library, one of which I could then expand to see all results within. In Windows 8, that functionality appears to be gone. The Search function in the Charms Bar lists tons of results by type (Documents, Pictures, et cetera) but not by Library. This is practically useless since Documents contains hundreds of .txt and .cs files, a few of which might be Books or Downloads. The only option I found is to go into Explorer and use the search bar in the Library section. However, there again, all search results are mixed together, and I can't seem to find a way to know which Library each result came from (in the Details view, I didn't find a Library column I could add). So, if I want to know which Library contains stuff about a given topic, I have to search the Libraries one by one. Very inconvenient. Is Microsoft slowly deprecating libraries? Any tips? How else can I search through libraries?

    Read the article

  • configure.in: AM_DISABLE_SHARED doesn't change my Makefile

    - by t2k32316
    I'm extremely new to using Makefiles and autoconf. I'm using the Camellia image library and trying to statically link my code against their libraries. When I run "make" on the Camellia image library, I get libCamellia.a, .so, .la, and .so.0.0.0 files inside my /usr/local/lib directory. This is the command I use to compile my code with their libraries: gcc -L/usr/local/lib -lCamellia -o myprogram myprogram.c This works fine, but when I try to statically link, this is what I get: gcc -static -L/usr/local/lib -lCamellia -o myprogram myprogram.c /tmp/cck0pw70.o: In function `main': myprogram.c:(.text+0x23): undefined reference to `camLoadPGM' myprogram.c:(.text+0x55): undefined reference to `camAllocateImage' myprogram.c:(.text+0x97): undefined reference to `camZoom2x' myprogram.c:(.text+0x104): undefined reference to `camSavePGM' collect2: ld returned 1 exit status I want to statically link because I'm trying to modify the Camellia source code and I want to compare my version against theirs. So after some googling, I tried adding AM_DISABLE_SHARED into the configure.in file. But after running ./configure, I still get the exact same Makefile. After I "make install", I still get the same results above. What is an easy way to get two versions of my code, one with the original Camellia source code compiled and one with my modified version? I think static libraries should work. There is an easy way to get static libraries working or are there other simple solutions to my problem? I just don't want to re-"make" and re-"make install" everytime I want to compare my version against the original.

    Read the article

  • XCode vs VS2008 or how to work with a static library project on XCode

    - by VansFannel
    Hello. I've working with Visual Studio for a long time and now I'm working with XCode. On Visual Studio I can work with more than one project at the same time adding them to a solution (imagine a solutin with a windows application project and a library project). Now I have XCode and two projects: an iPhone application and a static library. Is there something similar to Visual Studio's solution on XCode? If the answer is not, how can I link my iPhone application with the static library? Thank you.

    Read the article

  • Audio Static/Interference regardless of audio interface?

    - by Tom
    I currently am running a media center/server on a Lubuntu machine. The machine specs: Core 2 Duo Extreme EVGA SLI 680i MotherBoard 2 GB DDR2 Ram 3 Hard Drives no raid - WD Caviar Black, Green, and Samsung Spinpoint Galaxy GTX 220 1GB External USB Creative XI-FI Extreme Card 550W Power Supply This machine is hooked up through an optical cable to an ONKYO HTR340 Receiver through the XIFI card. Whenever I play any audio regardless if it is through XBMC, the default audio player, a flash video, etc, I get a horrible static sound that randomly gets louder. Here is a video of the sound: http://www.youtube.com/watch?v=SqKQkxYRVA4 This static comes in randomly, sometimes going away for short periods, but eventually always comes back. So far I have tried everything I could think of: Reinstalling OS Installing/upgrading/repairing PulseAudio/Alsa Installing alternate OSes, straight Ubuntu, Lubuntu, Xubuntu, Arch, Mint, Windows 7 Switching audio from the external card to internal Optical, audio out through HDMI, audio out through headphones Different ports on receiver (my main desktop sounds fine on the same sound system) Different optical cables Unplugging everything unnecessary from the motherboard (1 HD, 1 Stick of Ram, 1 Keyboard) Swapping out ram Swapping out the motherboard Replacing the Graphics Card (was replaced due to fan being noisy, not specifically for this problem) Different harddrives Swapping power supply Disabling onboard audio Pretty much everything short of swapping the CPU. I haven't been able to narrow down the problem and it is getting frustrating. Is it possible that the CPU is faulty and might cause a problem such as this, or that the PC case is shorting out the motherboard? Any kind of suggestions will be appreciated.

    Read the article

  • Advantages of Singleton Class over Static Class?

    Point 1)Singleton We can get the object of singleton and then pass to other methods.Static Class We can not pass static class to other methods as we pass objectsPoint 2) Singleton In future, it is easy to change the logic of of creating objects to some pooling mechanism. Static Class Very difficult to implement some pooling logic in case of static class. We would need to make that class as non-static and then make all the methods non-static methods, So entire your code needs to be changed.Point3:) Singleton Can Singletone class be inherited to subclass? Singleton class does not say any restriction of Inheritence. So we should be able to do this as long as subclass is also inheritence.There's nothing fundamentally wrong with subclassing a class that is intended to be a singleton. There are many reasons you might want to do it. and there are many ways to accomplish it. It depends on language you use.Static Class We can not inherit Static class to another Static class in C#. Think about it this way: you access static members via type name, like this: MyStaticType.MyStaticMember(); Were you to inherit from that class, you would have to access it via the new type name: MyNewType.MyStaticMember(); Thus, the new item bears no relationships to the original when used in code. There would be no way to take advantage of any inheritance relationship for things like polymorphism. span.fullpost {display:none;}

    Read the article

  • Advantages of Singleton Class over Static Class?

    Point 1) Singleton We can get the object of singleton and then pass to other methods. Static Class We can not pass static class to other methods as we pass objects Point 2) Singleton In future, it is easy to change the logic of of creating objects to some pooling mechanism. Static Class Very difficult to implement some pooling logic in case of static class. We would need to make that class as non-static and then make all the methods non-static methods, So entire your code needs to be changed. Point3:) Singleton Can Singletone class be inherited to subclass? Singleton class does not say any restriction of Inheritence. So we should be able to do this as long as subclass is also inheritence.There's nothing fundamentally wrong with subclassing a class that is intended to be a singleton. There are many reasons you might want to do it. and there are many ways to accomplish it. It depends on language you use. Static Class We can not inherit Static class to another Static class in C#. Think about it this way: you access static members via type name, like this: MyStaticType.MyStaticMember(); Were you to inherit from that class, you would have to access it via the new type name: MyNewType.MyStaticMember(); Thus, the new item bears no relationships to the original when used in code. There would be no way to take advantage of any inheritance relationship for things like polymorphism. span.fullpost {display:none;}

    Read the article

  • set static member pointer variables

    - by Chris
    I'm trying to set a static pointer variable in a class but I'm getting these errors for each variable I try to set. error C4430: missing type specifier - int assumed. Note: C++ does not support default-int error C2040: 'xscroll' : 'int' differs in levels of indirection from 'float *' error C2440: 'initializing' : cannot convert from 'float **' to 'int' Here is the code Enemy.h #include <windows.h> #include "Player.h" class Enemy { public: Enemy(float xPos, float yPos); Enemy(void); ~Enemy(void); //update the position of the user controlled object. void updatePosition(float timeFactor); //loads all the enemy textures void static loadTextures(); //creates a set number of enemies void static createEnemies(int numEnemies, Enemy * enemyArray); GLuint static enemyTex; static float * xscroll; static float * yscroll; static Player * player; private: bool checkCollison(float x, float y, int radius); float XPos; float YPos; }; trying to set variables Enemy::xscroll = &xscroll; Enemy::yscroll = &yscroll; Enemy::player = &player;

    Read the article

  • Java: Initializing a public static field in superclass that needs a different value in every subclas

    - by BinaryMuse
    Good evening, I am developing a set of Java classes so that a container class Box contains a List of a contained class Widget. A Widget needs to be able to specify relationships with other Widgets. I figured a good way to do this would be to do something like this: public abstract class Widget { public static class WidgetID { // implementation stolen from Google's GWT private static int nextHashCode; private final int index; public WidgetID() { index = ++nextHashCode; } public final int hashCode() { return index; } } public abstract WidgetID getWidgetID(); } so sublcasses of Widget could: public class BlueWidget extends Widget { public static final WidgetID WIDGETID = new WidgetID(); @Override public WidgetID getWidgetID() { return WIDGETID; } } Now, BlueWidget can do getBox().addWidgetRelationship(RelationshipTypes.SomeType, RedWidget.WIDGETID, and Box can iterate through it's list comparing the second parameter to iter.next().getWidgetID(). Now, all this works great so far. What I'm trying to do is keep from having to declare the public static final WidgetID WIDGETID in all the subclasses and implement it instead in the parent Widget class. The problem is, if I move that line of code into Widget, then every instance of a subclass of Widget appears to get the same static final WidgetID for their Subclassname.WIDGETID. However, making it non-static means I can no longer even call Subclassname.WIDGETID. So: how do I create a static WidgetID in the parent Widget class while ensuring it is different for every instance of Widget and subclasses of Widget? Or am I using the wrong tool for the job here? Thanks!

    Read the article

  • Problems adding static library QT project

    - by Smek
    I have problems adding a static library to my Qt project. I have two project one is my static library and the other one is a Qt GUI project. As I add all classes to my GUI project as c++ or header files everything works just fine but I want this to be in a separate library. When I select the option to add a library I check External library then I select the .a file I have build and the folder where my header files can be found because I am working on a Mac I select Mac as the target platform. Then I click continue and then done. macx: LIBS += -L$$PWD/../../MyLib/build-MyLib-Desktop_Qt_5_2_1_clang_64bit-Debug/ -lMyLib INCLUDEPATH += $$PWD/../../MyLib/build-MyLib-Desktop_Qt_5_2_1_clang_64bit-Debug/include DEPENDPATH += $$PWD/../../MyLib/build-MyLib-Desktop_Qt_5_2_1_clang_64bit-Debug/include macx: PRE_TARGETDEPS += $$PWD/../../MyLib/build-MyLib-Desktop_Qt_5_2_1_clang_64bit-Debug/libMyLib.a When I build my GUI project I get the following error: The process "/usr/bin/make" exited with code 2. Can anyone tell me what the problem can be and how to resolve the problem? Thanks

    Read the article

  • Static member function pointer to hold non static member function

    - by user1425406
    This has defeated me. I want to have a static class variable which is a pointer to a (non-static) member function. I've tried all sorts of ways, but with no luck (including using typedefs, which just seemed to give me a different set of errors). In the code below I have the static class function pointer funcptr, and I can call it successfully from outside the class, but not from within the member function CallFuncptr - which is what I want to do. Any suggestions? #include <stdio.h> class A { public: static int (A::*funcptr)(); int Four() { return 4;}; int CallFuncptr() { return (this->*funcptr)(); } // doesn't link - undefined reference to `A::funcptr' }; int (A::*funcptr)() = &A::Four; int main() { A fred; printf("four? %d\n", (fred.*funcptr)()); // This works printf("four? %d\n", fred.CallFuncptr()); // But this is the way I want to call it }

    Read the article

  • How do you structure your shared code so that it is "re-findable" for new developers?

    - by awmckinley
    I started working at my current job about 8 months ago, and its been one of the best experiences I've had as a young programmer. It's a small company, and both my co-developers are brilliant guys. One of the practices that they both have been encouraging is lots of code-reuse. Our code base is mainly C#, and we're using a centralized revision control system. The way the repository is currently structured, there is a single folder in which all shared class libraries are placed (along with unit tests for each library), and our revision control system allows for sharing or linking those libraries out to other projects. What I'm trying to understand at this point is how the current structure of the folder can be made more conducive for finding those libraries again. I've talked to the other developers about this, and they agree that it's gotten a little messy. I find that I am sometimes "reinventing the wheel" because I didn't realize that there was an existing piece of code that solved a particular problem. The issue is complicated further by the fact that we're sharing some code between ASP.NET MVC2, WinForms, and Windows CE projects, and sharing code between applications built against multiple versions of .NET. How do other people approach this? Is the answer in naming the libraries in a certain way or is it preferable to invest in some code-search software? Is the answer in doc comments? Should we be sharing libraries at all or should we simply branch the class libraries for re-use? Thanks for any and all help!

    Read the article

  • Static vs Non Static constructors

    - by Neil N
    I can't think of any reasons why one is better than the other. Compare these two implementations: public class MyClass { public myClass(string fileName) { // some code... } } as opposed to: public class MyClass { private myClass(){} public static Create(string fileName) { // some code... } } There are some places in the .Net framework that use the static method to create instances. At first I was thinking, it registers it's instances to keep track of them, but regular constructors could do the same thing through the use of private static variables. What is the reasoning behind this style?

    Read the article

  • Calling a static Func from a static class using reflection

    - by ChrisO
    Given the static class: public static class Converters { public static Func<Int64, string> Gold = c => String.Format("{0}g {1}s {2}c", c/10000, c/100%100, c%100); } I am receiving the Func name from a database as a string (regEx.Converter). How can I invoke the Gold Func using reflection? Here is what I have so far: var converter = typeof(Converters).GetMember(regEx.Converter); if (converter.Count() != 0) { //throw new ConverterNotFoundException; } matchedValue = converter.Invoke(null, new object[]{matchedValue}) as string;

    Read the article

  • Is it possible to call a non-static function inside static function in C#?

    - by djzmo
    Is it possible to call a non-static function that uses a public non-static class inside a static function in C#? public class MyProgram { private Thread thd = new Thread(myStaticFunction); public AnotherClass myAnotherClass = new AnotherClass(); public MyProgram() { thd.Start(); } public static void myStaticFunction() { myNonStaticFunction(); } private void myNonStaticFunction() { myAnotherClass.DoSomethingGood(); } } Well, the invalid code like above is what I need. Any idea?

    Read the article

  • Rails image_tag prefix to a static content

    - by pepernik
    I would like to server all static content from a different domain like static.mydomain.com. Is there an option every image_tag, javascript_include_tag and stylesheet_link_tag would automatically add a prefix to that static domain? Example: image_tag '/images/img1.png' would generate http://static.mydomain.com/images/img1.png Thx10x.

    Read the article

  • apache2 mod_deflate static content

    - by rizen
    I have a server serving up a JS file a few million times a day using apache2. Some of my users would like the JS to be gzipped. Does anyone know how apache2 mod_deflate handles compression of static files? Will it compress the js for each request(in which case I'd be worried about cpu load)? If it does, is there a way to pre-compress the JS files so apache2 wouldn't have to do this for each file?

    Read the article

  • Static DHCP!?

    - by voyager
    I've found some home wireless routers/ADSL+ modems (ZyXEL 660) talking about Static DHCP, when refering to assosiating a specific MAC to an IP, but still serve the configuration over DHCP. Doesn't this have another name? What does Cisco call this feature (that I know supports because I've used long time ago)?

    Read the article

  • Assigning static IP to VPN server

    - by Akroy
    I have a Win2008 R2 server that is going to be receiving many VPN connections. I want to be able to staticly set the IP addresses of both ends of each connection based on the user. I easily found how to do this for the client: when you're managing the user account, go to "Dial-In" and click "Assign Static IP Addresses." Now, whenever a certain account dials in, I have control over their client VIP, but how do I set my server VIP for each account?

    Read the article

< Previous Page | 6 7 8 9 10 11 12 13 14 15 16 17  | Next Page >